Skip to content

Commit

Permalink
test: _is_expected_filetype raises on multiple extensions and passes
Browse files Browse the repository at this point in the history
  • Loading branch information
r-leyshon committed Sep 18, 2023
1 parent d41fd1c commit 0af493b
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/utils/test_defence.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,47 @@ def test_is_expected_filetype_raises_single(self):
check_existing=True,
exp_ext=".tiff",
)

def test_is_expected_filetype_raises_multiple(self):
"""Test raises when `exp_ext` is a list of multiple file extensions."""
with pytest.raises(
ValueError,
match=re.escape(
"`raster` expected file extension ['.gif', '.jiff']. Found .ti"
),
):
_is_expected_filetype(
"some_raster.tiff",
"raster",
check_existing=False,
exp_ext=[".gif", ".jiff"],
)
with pytest.raises(
ValueError,
match=re.escape(
"`osm.pbf` expected file extension ['.zip', '.gif', '.pdf']. F"
),
):
_is_expected_filetype(
"tests/data/newport-2023-06-13.osm.pbf",
"osm.pbf",
check_existing=True,
exp_ext=[".zip", ".gif", ".pdf"],
)

def test_is_expected_filetype_on_pass(self):
"""Test when `exp_ext` passes."""
result = _is_expected_filetype(
"some_raster.tiff",
"raster",
check_existing=False,
exp_ext=[".gif", ".tiff"],
)
assert result is None
result = _is_expected_filetype(
"tests/data/newport-2023-06-13.osm.pbf",
"osm.pbf",
check_existing=True,
exp_ext=[".zip", ".gif", ".pbf"],
)
assert result is None

0 comments on commit 0af493b

Please sign in to comment.