]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - src/Tests/Unit/CensusTest.py
8 class DatabaseTest(unittest
.TestCase
):
11 self
.cdb
= Census
.Database()
14 def testEachBlockContainsItsOwnPopulation(self
):
15 # These calculations are slightly off due to a discrepancy
16 # between the WKB/WKT format calculations. It would appear
17 # that converting from WKB to WKT and then back loses some
20 # The error is 1/100th of a person. Should be pretty safe.
21 error_threshold
= 0.01
23 grp
= SummaryFile1
.GeoRecordParser()
24 fixtures_path
= Tests
.Fixtures
.Path() + '/SummaryFile1/one_hundred_records.txt'
25 fixtures
= grp
.parse_blocks(fixtures_path
)
28 block_boundary
= self
.cdb
.get_block_geometry_as_wkt(b
.blkidfp00())
29 contained_population
= self
.cdb
.find_contained_population(block_boundary
)
30 error
= abs(b
.pop100
- contained_population
)
31 self
.assertTrue(error
<= error_threshold
)
35 suite
= unittest
.TestSuite()
36 suite
.addTest(unittest
.makeSuite(DatabaseTest
))