Skip to content

Commit

Permalink
added temp dir to test_viz_stops_defence (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioRec authored Aug 30, 2023
1 parent 7b7bf27 commit 3d0a776
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions tests/gtfs/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ def test_print_alerts_multi_case(self, mocked_print, gtfs_fixture):
], f"Expected print statements about GTFS warnings. Found: {fun_out}"

@patch("builtins.print")
def test_viz_stops_defence(self, mocked_print, gtfs_fixture):
def test_viz_stops_defence(self, mocked_print, tmpdir, gtfs_fixture):
"""Check defensive behaviours of viz_stops()."""
tmp = os.path.join(tmpdir, "somefile.html")
with pytest.raises(
TypeError,
match="`out_pth` expected path-like, found <class 'bool'>",
Expand All @@ -147,23 +148,19 @@ def test_viz_stops_defence(self, mocked_print, gtfs_fixture):
with pytest.raises(
TypeError, match="`geoms` expects a string. Found <class 'int'>"
):
gtfs_fixture.viz_stops(out_pth="outputs/somefile.html", geoms=38)
gtfs_fixture.viz_stops(out_pth=tmp, geoms=38)
with pytest.raises(
ValueError, match="`geoms` must be either 'point' or 'hull."
):
gtfs_fixture.viz_stops(
out_pth="outputs/somefile.html", geoms="foobar"
)
gtfs_fixture.viz_stops(out_pth=tmp, geoms="foobar")
with pytest.raises(
TypeError,
match="`geom_crs`.*string or integer. Found <class 'float'>",
):
gtfs_fixture.viz_stops(
out_pth="outputs/somefile.html", geom_crs=1.1
)
gtfs_fixture.viz_stops(out_pth=tmp, geom_crs=1.1)
# check missing stop_id results in print instead of exception
gtfs_fixture.feed.stops.drop("stop_id", axis=1, inplace=True)
gtfs_fixture.viz_stops(out_pth="outputs/out.html")
gtfs_fixture.viz_stops(out_pth=tmp)
fun_out = mocked_print.mock_calls
assert fun_out == [
call("Key Error. Map was not written.")
Expand Down

0 comments on commit 3d0a776

Please sign in to comment.