]> gitweb.michael.orlitzky.com - dead/census-tools.git/blobdiff - src/Tests/Unit/CensusTest.py
Separate the tests that hit the database from the rest of the tests.
[dead/census-tools.git] / src / Tests / Unit / CensusTest.py
index 3f56afb3fbf0b9e0f425e5c626193e6c85684ddc..531d4dd0a615a2d7d27afbee8f0e36c5ebbe2cf1 100644 (file)
@@ -1,8 +1,6 @@
 import unittest
 
 import Census
-import Configuration.Defaults
-import GPS
 import SummaryFile1
 import Tests.Fixtures
 
@@ -10,10 +8,7 @@ import Tests.Fixtures
 class DatabaseTest(unittest.TestCase):
 
     def setUp(self):
-        self.cdb = Census.Database(Configuration.Defaults.DATABASE_HOST,
-                                   Configuration.Defaults.DATABASE_NAME,
-                                   Configuration.Defaults.DATABASE_USERNAME,
-                                   Configuration.Defaults.SRID)
+        self.cdb = Census.Database()
         
         
     def testEachBlockContainsItsOwnPopulation(self):
@@ -30,14 +25,20 @@ class DatabaseTest(unittest.TestCase):
         fixtures = grp.parse_blocks(fixtures_path)
         
         for b in fixtures:
-            block_boundary = self.cdb.get_block_geometry_as_wkt(b.tiger_blkidfp00())
+            block_boundary = self.cdb.get_block_geometry_as_wkt(b.blkidfp00())
             contained_population = self.cdb.find_contained_population(block_boundary)
             error = abs(b.pop100 - contained_population)
             self.assertTrue(error <= error_threshold)
             
     
 def suite():
+    # Tests that don't hit the database.
     suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(DatabaseTest))
     return suite
-        
+
+
+def db_suite():
+    # The tests that hit the database.
+    db_suite = unittest.TestSuite()
+    db_suite.addTest(unittest.makeSuite(DatabaseTest))
+    return db_suite