From 951edca6362e1bb5988db751b908de8fdc946d1e Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 12 Sep 2009 11:05:46 -0400 Subject: [PATCH] Added an additional Block class test which checks that all Maryland Geo Blocks have a population_density() which can be converted to a float. --- src/Tests/Unit/SummaryFile1Test.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) 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): -- 2.44.2