[Inteproxy-commits] r134 - in trunk: . test
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Jun 10 20:20:28 CEST 2008
Author: bh
Date: 2008-06-10 20:20:26 +0200 (Tue, 10 Jun 2008)
New Revision: 134
Added:
trunk/test/test_inteproxy.py
Modified:
trunk/ChangeLog
trunk/test/runtests.py
Log:
* test/test_inteproxy.py: New. Functional tests for InteProxy
* test/runtests.py (main): Remove proxy environment variables.
They may interfere with the InteProxy tests.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-06-10 18:13:39 UTC (rev 133)
+++ trunk/ChangeLog 2008-06-10 18:20:26 UTC (rev 134)
@@ -1,5 +1,12 @@
2008-06-10 Bernhard Herzog <bh at intevation.de>
+ * test/test_inteproxy.py: New. Functional tests for InteProxy
+
+ * test/runtests.py (main): Remove proxy environment variables.
+ They may interfere with the InteProxy tests.
+
+2008-06-10 Bernhard Herzog <bh at intevation.de>
+
* test/serversupport.py, test/test_httpserver.py: New files.
Support code for test cases that run http servers and test cases
for the support code and inteproxy.httpserver.
Modified: trunk/test/runtests.py
===================================================================
--- trunk/test/runtests.py 2008-06-10 18:13:39 UTC (rev 133)
+++ trunk/test/runtests.py 2008-06-10 18:20:26 UTC (rev 134)
@@ -51,6 +51,12 @@
dest="verbosity")
opts, rest = parser.parse_args()
+ # remove proxy environment variables. They may interfere with the
+ # inteproxy tests
+ for key in ["http_proxy", "https_proxy"]:
+ if key in os.environ:
+ del os.environ[key]
+
# Build the list of test names. If names were given on the command
# line, run exactly those. Othwerwise build a default list of
# names.
Added: trunk/test/test_inteproxy.py
===================================================================
--- trunk/test/test_inteproxy.py 2008-06-10 18:13:39 UTC (rev 133)
+++ trunk/test/test_inteproxy.py 2008-06-10 18:20:26 UTC (rev 134)
@@ -0,0 +1,64 @@
+# Copyright (C) 2007, 2008 by Intevation GmbH
+# Authors:
+# Bernhard Herzog <bh at intevation.de>
+#
+# This program is free software under the GPL (>=v2)
+# Read the file COPYING coming with the software for details.
+
+"""Functional tests for InteProxy"""
+
+import sys
+import os
+import httplib
+import unittest
+
+import serversupport
+
+from inteproxy.proxycore import MasterWorkerServer, InteProxyHTTPRequestHandler
+from inteproxy.main import build_opener
+import inteproxy.httpserver as httpserver
+
+
+
+class ServerTest(unittest.TestCase):
+
+ """Base class for tests that run the InteProxy in a thread"""
+
+ remote_contents = [
+ ("/wms", [("Content-Type", "text/plain")], "wms data"),
+ ]
+
+ def setUp(self):
+ self.old_stderr = sys.stderr
+ sys.stderr = open(os.path.devnull, "w")
+ proxyserver = MasterWorkerServer(("127.0.0.1", 0),
+ InteProxyHTTPRequestHandler, 5,
+ build_opener(None, 0),
+ build_opener(None, 0, 10))
+ self.server = httpserver.ServerThread(proxyserver)
+ self.server.start(daemon=True)
+ remote_server = serversupport.HTTPServer(self.remote_contents)
+ self.remote_server = httpserver.ServerThread(remote_server)
+ self.remote_server.start(daemon=True)
+ self.remote_server_base_url = "http://localhost:%d/" \
+ % (self.remote_server.server_port,)
+
+ def tearDown(self):
+ try:
+ self.remote_server.stop()
+ self.server.stop()
+ finally:
+ sys.stderr = self.old_stderr
+
+
+
+class TestInteProxy(ServerTest):
+
+ def test_httpproxy_passthrough(self):
+ http = httplib.HTTPConnection("localhost", self.server.server_port)
+ http.request("GET", self.remote_server_base_url + "wms")
+ response = http.getresponse()
+ self.assertEquals(response.status, 200)
+ data = response.read()
+ self.assertEquals(data, "wms data")
+
Property changes on: trunk/test/test_inteproxy.py
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
More information about the Inteproxy-commits
mailing list