bh: thuban/test test_postgis_db.py, 1.16, 1.17 postgissupport.py, 1.11, 1.12

cvs@intevation.de cvs at intevation.de
Thu Dec 16 15:19:23 CET 2004


Author: bh

Update of /thubanrepository/thuban/test
In directory doto:/tmp/cvs-serv25897/test

Modified Files:
	test_postgis_db.py postgissupport.py 
Log Message:
Make the test suite work with PostGIS 0.8.2 and PostgreSQL 7.4

* test/postgissupport.py (find_postgis_sql): Different postgis
versions put the postgis.sql file into slightly different places
so we have to look in both.  The updated doc string describes this
is more detail.

* test/test_postgis_db.py
(TestPostGISSpecialCases.test_column_name_quoting): The return
value of UniqueValues is unsorted, so it has to be sorted for
comparison.


Index: test_postgis_db.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_postgis_db.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- test_postgis_db.py	12 Mar 2004 12:59:33 -0000	1.16
+++ test_postgis_db.py	16 Dec 2004 14:19:21 -0000	1.17
@@ -233,7 +233,12 @@
         self.assertEquals(table.ReadValue(2, 1, row_is_ordinal = True), 3.0)
         self.assertEquals(table.ReadValue(2, 1, row_is_ordinal = False), 2.0)
         self.assertEquals(table.ValueRange("with space"), (1.0, 3.0))
-        self.assertEquals(table.UniqueValues("with \" quote"), [0, 1])
+
+        # The return value of UniqueValues is unsorted, so we need to
+        # sort it for comparison.
+        unique_values = table.UniqueValues("with \" quote")
+        unique_values.sort()
+        self.assertEquals(unique_values, [0, 1])
         self.assertEquals(table.SimpleQuery(table.Columns()[2], "==", 1),
                           [2, 3])
         self.assertEquals(table.SimpleQuery(table.Columns()[0], "==",

Index: postgissupport.py
===================================================================
RCS file: /thubanrepository/thuban/test/postgissupport.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- postgissupport.py	15 Dec 2004 14:01:04 -0000	1.11
+++ postgissupport.py	16 Dec 2004 14:19:21 -0000	1.12
@@ -495,15 +495,29 @@
     """Return the name of the postgis_sql file
 
     A postgis installation usually has the postgis_sql file in
-    PostgreSQL's datadir (i.e. the directory where PostgreSQL keeps
+    PostgreSQL's $datadir (i.e. the directory where PostgreSQL keeps
     static files, not the directory containing the databases).
     Unfortunately there's no way to determine the name of this directory
     with pg_config so we assume here that it's
     $bindir/../share/postgresql/.
+
+    Furthermore, different versions of postgis place the file in
+    slightly different locations.  For instance:
+
+      postgis 0.7.5        $datadir/contrib/postgis.sql
+      postgis 0.8.1        $datadir/postgis.sql
+
+    To support both versions, we look in both places and return the
+    first one found (looking under contrib first).  If the file is not
+    found the return value is None.
     """
     bindir = run_config_script("pg_config --bindir").strip()
-    return os.path.join(bindir, "..", "share", "postgresql",
-                        "contrib", "postgis.sql")
+    datadir = os.path.join(bindir, "..", "share", "postgresql")
+    for filename in [os.path.join(datadir, "contrib", "postgis.sql"),
+                     os.path.join(datadir, "postgis.sql")]:
+        if os.path.exists(filename):
+            return filename
+
 
 _postgres_server = None
 def get_test_server():





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)