]> gitweb.michael.orlitzky.com - dead/census-tools.git/blob - src/Tests/Unit/LEHDTest.py
Added an LEHD module, with classes to parse Origin-Destination matrix files.
[dead/census-tools.git] / src / Tests / Unit / LEHDTest.py
1 import unittest
2
3 import Tests.Fixtures
4 from Errors import RecordError
5 import LEHD
6
7
8 class OriginDestinationRecordParserTest(unittest.TestCase):
9
10 def setUp(self):
11 self.odrp = LEHD.OriginDestinationRecordParser()
12
13
14 def testAllOfSubsetParsed(self):
15 fixture_path = Tests.Fixtures.Path() + '/LEHD/ten_records.csv'
16 records = self.odrp.parse_file(fixture_path)
17 self.assertEqual(len(records), 10)
18
19
20 def testErrorOnMissingColumns(self):
21 fixture_path = Tests.Fixtures.Path() + '/LEHD/ten_records-twelve_columns.csv'
22 self.assertRaises(RecordError, self.odrp.parse_file, fixture_path)
23
24
25 def testErrorOnMissingHeader(self):
26 fixture_path = Tests.Fixtures.Path() + '/LEHD/ten_records-no_header.csv'
27 self.assertRaises(RecordError, self.odrp.parse_file, fixture_path)
28
29 def suite():
30 suite = unittest.TestSuite()
31 suite.addTest(unittest.makeSuite(OriginDestinationRecordParserTest))
32 return suite