Skip to content

Commit

Permalink
chore: update tests to not rely on warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AngRodrigues committed Dec 5, 2024
1 parent 1c55458 commit 02e3003
Showing 1 changed file with 14 additions and 31 deletions.
45 changes: 14 additions & 31 deletions tests/mapdata/test_set_get_working_projection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest

from map2loop.mapdata import MapData


Expand All @@ -10,24 +9,9 @@
("EPSG:3857", "EPSG:3857", None, None), # happy path with str projection
(9999, "EPSG:9999", None, None), # edge case with high int projection
("EPSG:9999", "EPSG:9999", None, None), # edge case with high str projection
(
None,
None,
None,
"Warning: Unknown projection set None. Leaving all map data in original projection\n",
), # error case with None
(
[],
None,
None,
"Warning: Unknown projection set []. Leaving all map data in original projection\n",
), # error case with list
(
{},
None,
None,
"Warning: Unknown projection set {}. Leaving all map data in original projection\n",
), # error case with dict
(None, None, None, True), # error case with None
([], None, None, True), # error case with list
({}, None, None, True), # error case with dict
],
ids=[
"int_projection",
Expand All @@ -39,22 +23,21 @@
"dict_projection",
],
)
def test_set_working_projection(
projection, expected_projection, bounding_box, expected_warning, capsys
):

def test_set_working_projection(projection, expected_projection, bounding_box, expected_warning):
# Set up MapData object
map_data = MapData()
map_data.bounding_box = bounding_box

# Call the method
map_data.set_working_projection(projection)

assert (
map_data.working_projection == expected_projection
), "Map.data set_working_projection() not attributing the correct projection"
# Assert the working projection is correctly set
assert map_data.working_projection == expected_projection, (
f"Expected working_projection to be {expected_projection}, but got {map_data.working_projection}"
)

# Check for the presence of warnings via side effects (if applicable)
if expected_warning:
captured = capsys.readouterr()
assert expected_warning in captured.out
else:
captured = capsys.readouterr()
assert captured.out == ""
assert map_data.working_projection is None, (
"Expected working_projection to remain None when an invalid projection is provided"
)

0 comments on commit 02e3003

Please sign in to comment.