]> gitweb.michael.orlitzky.com - dead/census-tools.git/blobdiff - src/Tests/Unit/KMLTest.py
Added the KMLTest module containing the LineString tests.
[dead/census-tools.git] / src / Tests / Unit / KMLTest.py
diff --git a/src/Tests/Unit/KMLTest.py b/src/Tests/Unit/KMLTest.py
new file mode 100644 (file)
index 0000000..579ba22
--- /dev/null
@@ -0,0 +1,42 @@
+import unittest
+
+import Tests.Fixtures
+from KML import *
+
+
+class LineStringTest(unittest.TestCase):
+
+    def testTuplesFromKml(self):
+        """
+        Make sure we parse KML LineStrings into tuples properly.
+        """
+
+        fixture_path = Tests.Fixtures.Path() + '/KML/linestring1.kml'
+        f = open(fixture_path, 'r')
+        kml = f.read()
+        f.close()
+        
+        actual_tuples = LineString.tuples_from_kml(kml)
+        
+        expected_tuples = [ (-76.62861599999999, 39.315609),
+                            (-76.62606, 39.312859),
+                            (-76.62496899999999, 39.311951),
+                            (-76.624062, 39.31134),
+                            (-76.620209, 39.30901),
+                            (-76.61734, 39.307499),
+                            (-76.616272, 39.306782),
+                            (-76.61550099999999, 39.30632),
+                            (-76.614952, 39.306091),
+                            (-76.614441, 39.305962),
+                            (-76.613983, 39.305908),
+                            (-76.613152, 39.305939),
+                            (-76.612534, 39.305889),
+                            (-76.612038, 39.30571) ]
+        
+        self.assertEqual(expected_tuples, actual_tuples)
+
+
+def suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(LineStringTest))
+    return suite