Skip to content

Commit

Permalink
Add a unit test to confirm all coordinates
Browse files Browse the repository at this point in the history
Make sure that all the required coordinates are in the GeoRSS string,
to avoid the mistake made earlier.
  • Loading branch information
om-henners committed Jul 8, 2019
1 parent b02278e commit 9586e7b
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/test_extensions/test_geo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from itertools import chain
import unittest
import warnings

Expand Down Expand Up @@ -296,6 +297,21 @@ def test_geom_from_geointerface_point(self):
namespaces=ns)
self.assertEqual(point, [str(self.point)])

coords = [float(c) for c in point[0].split()]

try:
self.assertCountEqual(
coords,
self.point.coords
)
except AttributeError: # was assertItemsEqual in Python 2.7
self.assertItemsEqual(
coords,
list(chain.from_iterable(self.point.coords))
)



def test_geom_from_geointerface_line(self):
fe = self.fg.add_item()
fe.title('y')
Expand All @@ -310,6 +326,20 @@ def test_geom_from_geointerface_line(self):
namespaces=ns)
self.assertEqual(line, [str(self.line)])

coords = [float(c) for c in line[0].split()]

try:
self.assertCountEqual(
coords,
list(chain.from_iterable(self.line.coords))
)
except AttributeError: # was assertItemsEqual in Python 2.7
self.assertItemsEqual(
coords,
list(chain.from_iterable(self.line.coords))
)


def test_geom_from_geointerface_poly(self):
fe = self.fg.add_item()
fe.title('y')
Expand All @@ -324,6 +354,19 @@ def test_geom_from_geointerface_poly(self):
namespaces=ns)
self.assertEqual(poly, [str(self.polygon)])

coords = [float(c) for c in poly[0].split()]

try:
self.assertCountEqual(
coords,
list(chain.from_iterable(self.polygon.coords[0]))
)
except AttributeError: # was assertItemsEqual in Python 2.7
self.assertItemsEqual(
coords,
list(chain.from_iterable(self.polygon.coords[0]))
)

def test_geom_from_geointerface_fail_other_geom(self):
fe = self.fg.add_item()
fe.title('y')
Expand Down Expand Up @@ -366,3 +409,16 @@ def test_geom_from_geointerface_warn_poly_interior(self):
poly = root.xpath('/rss/channel/item/georss:polygon/text()',
namespaces=ns)
self.assertEqual(poly, [str(self.polygon_with_interior)])

coords = [float(c) for c in poly[0].split()]

try:
self.assertCountEqual(
coords,
list(chain.from_iterable(self.polygon_with_interior.coords[0]))
)
except AttributeError: # was assertItemsEqual in Python 2.7
self.assertItemsEqual(
coords,
list(chain.from_iterable(self.polygon_with_interior.coords[0]))
)

0 comments on commit 9586e7b

Please sign in to comment.