[Inteproxy-commits] r191 - in trunk: . inteproxy test

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Sep 1 17:45:56 CEST 2009


Author: bh
Date: 2009-09-01 17:45:54 +0200 (Tue, 01 Sep 2009)
New Revision: 191

Modified:
   trunk/ChangeLog
   trunk/inteproxy/transcoder.py
   trunk/test/test_transcoder_map.py
Log:
* test/test_transcoder_map.py (TestTranscoderMap.setUp)
(TestTranscoderMap.test_lookup)
(TestTranscoderMap.test_get_transcoder_http_proxy)
(TestTranscoderMap.test_get_transcoder_inteproxy_style): Use the
newer way to read the configuration

* inteproxy/transcoder.py (TranscoderMap.read_config): Remove this
unused method.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-03-26 20:08:11 UTC (rev 190)
+++ trunk/ChangeLog	2009-09-01 15:45:54 UTC (rev 191)
@@ -1,3 +1,14 @@
+2009-09-01  Bernhard Herzog  <bh at intevation.de>
+
+	* test/test_transcoder_map.py (TestTranscoderMap.setUp)
+	(TestTranscoderMap.test_lookup)
+	(TestTranscoderMap.test_get_transcoder_http_proxy)
+	(TestTranscoderMap.test_get_transcoder_inteproxy_style): Use the
+	newer way to read the configuration
+
+	* inteproxy/transcoder.py (TranscoderMap.read_config): Remove this
+	unused method.
+
 2009-03-26  Bernhard Herzog  <bh at intevation.de>
 
 	* apache/README.txt: New.  README file for the apache version of

Modified: trunk/inteproxy/transcoder.py
===================================================================
--- trunk/inteproxy/transcoder.py	2009-03-26 20:08:11 UTC (rev 190)
+++ trunk/inteproxy/transcoder.py	2009-09-01 15:45:54 UTC (rev 191)
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, 2008 by Intevation GmbH
+# Copyright (C) 2007, 2008, 2009 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 #
@@ -241,16 +241,6 @@
         return transcoder_class(method,
                                 (scheme, netloc, path, query, fragment))
 
-    def read_config(self, filename):
-        """Reads a configuration file and adds the host descriptions found"""
-        parser = SafeConfigParser()
-        parser.read([filename])
-        for section in parser.sections():
-            host = parser.get(section, "host")
-            path = parser.get(section, "path")
-            cls = parser.get(section, "class")
-            self.add_host(host, path, cls)
-
     def rewrite_urls(self, data, prefix, log_debug):
         """Prefix all known URLs in data with prefix.
 

Modified: trunk/test/test_transcoder_map.py
===================================================================
--- trunk/test/test_transcoder_map.py	2009-03-26 20:08:11 UTC (rev 190)
+++ trunk/test/test_transcoder_map.py	2009-09-01 15:45:54 UTC (rev 191)
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, 2008 by Intevation GmbH
+# Copyright (C) 2007, 2008, 2009 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh at intevation.de>
 #
@@ -14,8 +14,8 @@
 from inteproxy.transcoder import create_transcoder_map, \
      OWSProxyGETTranscoder, OWSProxyPOSTTranscoder, BasicAuthTranscoder, \
      IdentityTranscoder
+import inteproxy.config
 
-
 class TestTranscoderMap(unittest.TestCase, support.FileTestMixin):
 
     config_contents = """\
@@ -32,14 +32,13 @@
     #
 
     def setUp(self):
-        self.config_filename = self.create_temp_file(self.id(),
-                                                     self.config_contents)
+        config_filename = self.create_temp_file(self.id(), self.config_contents)
+        config = inteproxy.config.read_config(config_filename)
+        self.transcoder_map = create_transcoder_map()
+        self.transcoder_map.add_hosts(config.hosts)
 
     def test_lookup(self):
         """Test the lookup method"""
-        transcoder_map = create_transcoder_map()
-        transcoder_map.read_config(self.config_filename)
-
         test_cases = [
             ("GET", "inteproxy-demo.intevation.org", "/cgi-bin/frida-wms",
              OWSProxyGETTranscoder),
@@ -61,16 +60,13 @@
             ]
 
         for method, host, path, expectedcls in test_cases:
-            cls = transcoder_map.lookup(method, host, path)
+            cls = self.transcoder_map.lookup(method, host, path)
             msg=("Wrong class for %(method)s %(host)s%(path)s:"
                  " got %(cls)s expected %(expectedcls)s" % locals())
             self.assertEquals(cls, expectedcls, msg)
 
     def test_get_transcoder_http_proxy(self):
         """Test the get_transcoder method in http-proxy mode"""
-        transcoder_map = create_transcoder_map()
-        transcoder_map.read_config(self.config_filename)
-
         test_cases = [
             ("GET", "http://inteproxy-demo.intevation.org/cgi-bin/frida-wms",
              OWSProxyGETTranscoder),
@@ -91,7 +87,7 @@
             ]
 
         for method, url, expectedcls in test_cases:
-            transcoder = transcoder_map.get_transcoder(method, url)
+            transcoder = self.transcoder_map.get_transcoder(method, url)
             cls = transcoder.__class__
             msg=("Wrong class for %(method)s %(url)s:"
                  " got %(cls)s expected %(expectedcls)s" % locals())
@@ -99,9 +95,6 @@
 
     def test_get_transcoder_inteproxy_style(self):
         """Test the get_transcoder method in InteProxy mode"""
-        transcoder_map = create_transcoder_map()
-        transcoder_map.read_config(self.config_filename)
-
         test_cases = [
             ("GET", "/inteproxy-demo.intevation.org/cgi-bin/frida-wms",
              OWSProxyGETTranscoder),
@@ -117,7 +110,7 @@
             ]
 
         for method, url, expectedcls in test_cases:
-            transcoder = transcoder_map.get_transcoder(method, url)
+            transcoder = self.transcoder_map.get_transcoder(method, url)
             cls = transcoder.__class__
             msg=("Wrong class for %(method)s %(url)s:"
                  " got %(cls)s expected %(expectedcls)s" % locals())



More information about the Inteproxy-commits mailing list