From ac2fc44b50f34ee8694b80c2389687a9e3c5d842 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 25 Oct 2009 18:12:34 -0400 Subject: [PATCH] Added the KMLTest module containing the LineString tests. --- src/Tests/Fixtures/KML/linestring1.kml | 12 ++++++++ src/Tests/Unit/KMLTest.py | 42 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/Tests/Fixtures/KML/linestring1.kml create mode 100644 src/Tests/Unit/KMLTest.py diff --git a/src/Tests/Fixtures/KML/linestring1.kml b/src/Tests/Fixtures/KML/linestring1.kml new file mode 100644 index 0000000..3002aae --- /dev/null +++ b/src/Tests/Fixtures/KML/linestring1.kml @@ -0,0 +1,12 @@ + + + + Test LineString #1 + + 1 + + -76.62861599999999,39.315609,0 -76.62606,39.312859,0 -76.62496899999999,39.311951,0 -76.624062,39.31134,0 -76.620209,39.30901,0 -76.61734,39.307499,0 -76.616272,39.306782,0 -76.61550099999999,39.30632,0 -76.614952,39.306091,0 -76.614441,39.305962,0 -76.613983,39.305908,0 -76.613152,39.305939,0 -76.612534,39.305889,0 -76.612038,39.30571,0 + + + + diff --git a/src/Tests/Unit/KMLTest.py b/src/Tests/Unit/KMLTest.py new file mode 100644 index 0000000..579ba22 --- /dev/null +++ b/src/Tests/Unit/KMLTest.py @@ -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 -- 2.44.2