]> gitweb.michael.orlitzky.com - dead/census-tools.git/blobdiff - 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
diff --git a/src/Tests/Unit/LEHDTest.py b/src/Tests/Unit/LEHDTest.py
new file mode 100644 (file)
index 0000000..ca3013e
--- /dev/null
@@ -0,0 +1,32 @@
+import unittest
+
+import Tests.Fixtures
+from Errors import RecordError
+import LEHD
+
+
+class OriginDestinationRecordParserTest(unittest.TestCase):
+
+    def setUp(self):
+        self.odrp = LEHD.OriginDestinationRecordParser()
+
+        
+    def testAllOfSubsetParsed(self):
+        fixture_path = Tests.Fixtures.Path() + '/LEHD/ten_records.csv'
+        records = self.odrp.parse_file(fixture_path)
+        self.assertEqual(len(records), 10)
+
+
+    def testErrorOnMissingColumns(self):
+        fixture_path = Tests.Fixtures.Path() + '/LEHD/ten_records-twelve_columns.csv'
+        self.assertRaises(RecordError, self.odrp.parse_file, fixture_path)
+
+
+    def testErrorOnMissingHeader(self):
+        fixture_path = Tests.Fixtures.Path() + '/LEHD/ten_records-no_header.csv'
+        self.assertRaises(RecordError, self.odrp.parse_file, fixture_path)           
+    
+def suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(OriginDestinationRecordParserTest))
+    return suite