]> gitweb.michael.orlitzky.com - dead/census-tools.git/blobdiff - src/Tests/Unit/SummaryFile1Test.py
Added an additional Block class test which checks that all Maryland Geo Blocks have...
[dead/census-tools.git] / src / Tests / Unit / SummaryFile1Test.py
index a29e208cf7fa91ee2bbc20ce186b9f01e1d63d02..18825dde9c10d3ced05cade2364173948c70d0b2 100644 (file)
@@ -1,9 +1,18 @@
-import Tests.Fixtures, SummaryFile1, GPS, unittest
+import unittest
+
+import Tests.Fixtures
+import SummaryFile1
+import GPS
+import StringUtils
 
 
 class BlockTest(unittest.TestCase):
 
-    def testAverageDensityIsFloat(self):
+    def setUp(self):
+        self.grp = SummaryFile1.GeoRecordParser()
+
+
+    def testOneAverageDensityIsFloat(self):
         """
         We want to make sure no float->integer truncation
         is taking place.
@@ -12,6 +21,9 @@ class BlockTest(unittest.TestCase):
         # Fill a GeoRecord with dummy values so that we
         # can calculate its average population density.
         gr = SummaryFile1.GeoRecord()
+        gr.state = '24'
+        gr.county = '001'
+        gr.tract = '123456'
         gr.block = '1728'
         gr.pop100 = '100'
         gr.arealand = '40'
@@ -25,7 +37,22 @@ class BlockTest(unittest.TestCase):
         # intepreted as a float.
         self.assertEqual(b.population_density(), 1.25)
 
-        
+
+
+    def testAllAverageDensitiesAreFloat(self):
+        """
+        Test every GeoRecord in the Maryland file, and make sure
+        all of the average densities can be parsed as floats.
+        """
+
+        fixture_path = Tests.Fixtures.Path() + '/SummaryFile1/mdgeo.uf1'
+        blocks = self.grp.parse_blocks(fixture_path)
+
+        for b in blocks:
+            self.assertTrue(StringUtils.is_float(b.population_density()))
+
+
+
 class GeoRecordParserTest(unittest.TestCase):
 
     def setUp(self):
@@ -80,7 +107,7 @@ class SummaryFile1Test(unittest.TestCase):
             b_coords.longitude = b.coordinates.longitude
             
             closest_block = SummaryFile1.FindClosestBlock(blocks, b_coords)
-            self.assertEqual(b.block_number, closest_block.block_number)
+            self.assertEqual(b.block, closest_block.block)
 
 
     def testEachBlockHasItsOwnAverageDensity(self):