Skip to content

Commit

Permalink
Issue #128: add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
enzet committed Jun 6, 2022
1 parent 7a56d0d commit 8dbc03c
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions tests/test_ways.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@


def get_constructor(osm_data: OSMData) -> Constructor:
"""
Get custom constructor for bounds (-0.01, -0.01, 0.01, 0.01) and zoom level
18.
"""
flinger: Flinger = Flinger(
BoundaryBox(-0.01, -0.01, 0.01, 0.01), 18, osm_data.equator_length
)
Expand All @@ -26,13 +30,15 @@ def get_constructor(osm_data: OSMData) -> Constructor:
return constructor


def create_way(tags: Tags, index: int) -> OSMWay:
def create_way(osm_data: OSMData, tags: Tags, index: int) -> None:
"""Create simple OSM way with two arbitrary nodes."""
nodes: list[OSMNode] = [
OSMNode({}, 1, np.array((-0.01, -0.01))),
OSMNode({}, 2, np.array((0.01, 0.01))),
]
return OSMWay(tags, index, nodes)
for node in nodes:
osm_data.add_node(node)
osm_data.add_way(OSMWay(tags, index, nodes))


def test_river_and_wood() -> None:
Expand All @@ -42,8 +48,8 @@ def test_river_and_wood() -> None:
See https://github.com/enzet/map-machine/issues/126
"""
osm_data: OSMData = OSMData()
osm_data.add_way(create_way({"natural": "wood"}, 1))
osm_data.add_way(create_way({"waterway": "river"}, 2))
create_way(osm_data, {"natural": "wood"}, 1)
create_way(osm_data, {"waterway": "river"}, 2)

figures: list[Figure] = get_constructor(osm_data).get_sorted_figures()

Expand All @@ -52,6 +58,19 @@ def test_river_and_wood() -> None:
assert figures[1].tags["waterway"] == "river"


def test_placement_and_lanes() -> None:
"""
Check that `placement` tag is processed correctly when `lanes` tag is not
specified.
See https://github.com/enzet/map-machine/issues/128
"""
osm_data: OSMData = OSMData()
create_way(osm_data, {"highway": "motorway", "placement": "right_of:2"}, 1)

get_constructor(osm_data)


def test_empty_ways() -> None:
"""Ways without nodes."""
osm_data: OSMData = OSMData()
Expand Down

0 comments on commit 8dbc03c

Please sign in to comment.