|
1 | 1 | from itertools import chain
|
| 2 | +from typing import Any, Iterable |
2 | 3 |
|
3 | 4 | import pytest
|
4 | 5 |
|
|
130 | 131 | )
|
131 | 132 |
|
132 | 133 |
|
| 134 | +def assert_line_strings_are_equals(geometry, expected_geometry): |
| 135 | + assert geometry["type"] == expected_geometry["type"] |
| 136 | + assert list(chain.from_iterable(geometry["coordinates"])) == pytest.approx( |
| 137 | + list(chain.from_iterable(expected_geometry["coordinates"])) |
| 138 | + ) |
| 139 | + |
| 140 | + |
| 141 | +def assert_points_are_equals(geometry, expected_geometry): |
| 142 | + assert geometry["type"] == expected_geometry["type"] |
| 143 | + assert geometry["coordinates"] == pytest.approx(expected_geometry["coordinates"]) |
| 144 | + |
| 145 | + |
| 146 | +def assert_steps_are_equals(steps: Iterable[Any], expected_steps: Iterable[Any]): |
| 147 | + assert len(steps) == len(expected_steps) |
| 148 | + |
| 149 | + for i in range(len(steps)): |
| 150 | + assert_points_are_equals(steps[i].pop("sch"), expected_steps[i].pop("sch")) |
| 151 | + assert_points_are_equals(steps[i].pop("geo"), expected_steps[i].pop("geo")) |
| 152 | + assert steps[i] == expected_steps[i] |
| 153 | + |
| 154 | + |
133 | 155 | def test_west_to_south_east_path(west_to_south_east_path: Path):
|
134 | 156 | assert west_to_south_east_path.owner == _EXPECTED_WEST_TO_SOUTH_EAST_PATH.owner
|
135 | 157 | assert west_to_south_east_path.slopes == pytest.approx(_EXPECTED_WEST_TO_SOUTH_EAST_PATH.slopes)
|
136 | 158 | assert west_to_south_east_path.curves == pytest.approx(_EXPECTED_WEST_TO_SOUTH_EAST_PATH.curves)
|
137 |
| - assert west_to_south_east_path.steps == _EXPECTED_WEST_TO_SOUTH_EAST_PATH.steps |
138 |
| - assert west_to_south_east_path.geographic["type"] == _EXPECTED_WEST_TO_SOUTH_EAST_PATH.geographic["type"] |
139 |
| - assert list(chain.from_iterable(west_to_south_east_path.geographic["coordinates"])) == pytest.approx( |
140 |
| - list(chain.from_iterable(_EXPECTED_WEST_TO_SOUTH_EAST_PATH.geographic["coordinates"])) |
141 |
| - ) |
142 |
| - assert west_to_south_east_path.schematic["type"] == _EXPECTED_WEST_TO_SOUTH_EAST_PATH.schematic["type"] |
143 |
| - assert list(chain.from_iterable(west_to_south_east_path.schematic["coordinates"])) == pytest.approx( |
144 |
| - list(chain.from_iterable(_EXPECTED_WEST_TO_SOUTH_EAST_PATH.schematic["coordinates"])) |
145 |
| - ) |
| 159 | + assert_steps_are_equals(west_to_south_east_path.steps, _EXPECTED_WEST_TO_SOUTH_EAST_PATH.steps) |
| 160 | + |
| 161 | + assert_line_strings_are_equals(west_to_south_east_path.geographic, _EXPECTED_WEST_TO_SOUTH_EAST_PATH.geographic) |
| 162 | + assert_line_strings_are_equals(west_to_south_east_path.schematic, _EXPECTED_WEST_TO_SOUTH_EAST_PATH.schematic) |
0 commit comments