From: Michael Orlitzky Date: Sat, 12 Sep 2009 15:05:46 +0000 (-0400) Subject: Added an additional Block class test which checks that all Maryland Geo Blocks have... X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=951edca6362e1bb5988db751b908de8fdc946d1e;p=dead%2Fcensus-tools.git Added an additional Block class test which checks that all Maryland Geo Blocks have a population_density() which can be converted to a float. --- diff --git a/src/Tests/Unit/SummaryFile1Test.py b/src/Tests/Unit/SummaryFile1Test.py index edaf598..18825dd 100644 --- a/src/Tests/Unit/SummaryFile1Test.py +++ b/src/Tests/Unit/SummaryFile1Test.py @@ -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. @@ -28,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):