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