Skip to content

Commit

Permalink
more interface tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ajfriend committed Nov 10, 2023
1 parent 8922cc8 commit e9041fc
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions tests/polyfill/test_h3.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,9 @@ def test_poly_opens_loop():


def test_geo_to_h3shape():
mock_open = get_mocked(loop_open())
mock_closed = get_mocked(loop_closed())

h3shape_open = h3.geo_to_h3shape(mock_open)
h3shape_closed = h3.geo_to_h3shape(mock_closed)
loops = [loop_open(), loop_closed()]
mocks = map(get_mocked, loops)
h3shapes = map(h3.geo_to_h3shape, mocks)

expected = {
'type': 'Polygon',
Expand All @@ -149,10 +147,10 @@ def test_geo_to_h3shape():
),)
}

assert h3shape_open.__geo_interface__ == expected
assert h3shape_closed.__geo_interface__ == expected
for shape in h3shapes:
assert shape.__geo_interface__ == expected

mpoly = h3.H3MultiPoly(h3shape_open)
mpolys = map(h3.H3MultiPoly, h3shapes)

multi_expected = {
'type': 'MultiPolygon',
Expand All @@ -164,7 +162,16 @@ def test_geo_to_h3shape():
),),)
}

assert mpoly.__geo_interface__ == multi_expected
for mp in mpolys:
assert mp.__geo_interface__ == multi_expected


def test_geo_to_h3shape_passthrough():
poly = h3.H3Poly(loop_open())
mpoly = h3.H3MultiPoly(poly)

for shape in [poly, mpoly]:
assert h3.geo_to_h3shape(shape) is shape


def test_polyfill_down_under():
Expand Down

0 comments on commit e9041fc

Please sign in to comment.