]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - 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 # Tests that don't hit the database.
36 suite
= unittest
.TestSuite()
41 # The tests that hit the database.
42 db_suite
= unittest
.TestSuite()
43 db_suite
.addTest(unittest
.makeSuite(DatabaseTest
))