Skip to content

Commit

Permalink
refactor: Flatten out fixtures & correct expected test paths
Browse files Browse the repository at this point in the history
  • Loading branch information
r-leyshon committed Jul 3, 2024
1 parent a50508a commit 8e28c4d
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 33 deletions.
Binary file removed tests/data/gtfs/newport-20230613_gtfs.zip
Binary file not shown.
6 changes: 0 additions & 6 deletions tests/data/gtfs/report/html_template.html

This file was deleted.

4 changes: 1 addition & 3 deletions tests/report/test_report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
@pytest.fixture(scope="function")
def template_fixture():
"""Fixture for test funcs expecting a valid feed object."""
template = TemplateHTML(
path=here("tests/data/gtfs/report/html_template.html")
)
template = TemplateHTML(path=here("tests/data/report/html_template.html"))
return template


Expand Down
4 changes: 1 addition & 3 deletions tests/test_gtfs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
from assess_gtfs.validation import GtfsInstance

# location of GTFS test fixture
GTFS_FIX_PTH = os.path.join(
"tests", "data", "gtfs", "newport-20230613_gtfs.zip"
)
GTFS_FIX_PTH = os.path.join("tests", "data", "newport-20230613_gtfs.zip")


class TestFilterGtfs(object):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_multi_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def multi_gtfs_paths():
"""Small test fixture for GTFS paths."""
paths = [
"tests/data/chester-20230816-small_gtfs.zip",
"tests/data/gtfs/newport-20230613_gtfs.zip",
"tests/data/newport-20230613_gtfs.zip",
]
return paths

Expand Down
4 changes: 1 addition & 3 deletions tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ class Test_GetSavedRouteTypeLookup(object):
# test raises from key _is_expected_filetype() defences
(
pathlib.Path(
os.path.join(
"tests", "data", "gtfs", "newport-20230613_gtfs.zip"
)
os.path.join("tests", "data", "newport-20230613_gtfs.zip")
),
pytest.raises(
ValueError,
Expand Down
16 changes: 5 additions & 11 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
_get_intermediate_dates,
)

GTFS_FIX_PTH = os.path.join(
"tests", "data", "gtfs", "newport-20230613_gtfs.zip"
)
GTFS_FIX_PTH = os.path.join("tests", "data", "newport-20230613_gtfs.zip")


@pytest.fixture(scope="function") # some funcs expect cleaned feed others dont
Expand Down Expand Up @@ -58,9 +56,7 @@ def test_init_defensive_behaviours(self):
ValueError,
match=r"`gtfs_pth` expected file extension .zip. Found .html",
):
GtfsInstance(
gtfs_pth=here("tests/data/gtfs/report/html_template.html")
)
GtfsInstance(gtfs_pth=here("tests/data/report/html_template.html"))
with pytest.raises(
ValueError,
match=(
Expand All @@ -70,9 +66,7 @@ def test_init_defensive_behaviours(self):
):
GtfsInstance(
gtfs_pth=GTFS_FIX_PTH,
route_lookup_pth=here(
"tests/data/gtfs/report/html_template.html"
),
route_lookup_pth=here("tests/data/report/html_template.html"),
)
# handling units
with pytest.raises(
Expand Down Expand Up @@ -746,7 +740,7 @@ def test_summarise_trips_on_pass(self, gtfs_fixture):
).all(), f"Columns were not as expected. Found {found_drc}"

# tests the output of the daily_route_summary table
# using data/gtfs/newport-20230613_gtfs.zip
# using data/newport-20230613_gtfs.zip
expected_df = pd.DataFrame(
{
"day": {0: "friday", 1: "friday"},
Expand Down Expand Up @@ -826,7 +820,7 @@ def test_summarise_routes_on_pass(self, gtfs_fixture):
).all(), f"Columns were not as expected. Found {found_drc}"

# tests the output of the daily_route_summary table
# using tests/data/gtfs/newport-20230613_gtfs.zip
# using tests/data/newport-20230613_gtfs.zip
expected_df = pd.DataFrame(
{
"day": {0: "friday", 1: "friday"},
Expand Down
8 changes: 3 additions & 5 deletions tests/utils/test_defence.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,7 @@ def test_is_expected_filetype_raises_single(self):
match="`gtfs.zip` expected file extension .tiff. Found .zip",
):
_is_expected_filetype(
os.path.join(
"tests", "data", "gtfs", "newport-20230613_gtfs.zip"
),
os.path.join("tests", "data", "newport-20230613_gtfs.zip"),
param_nm="gtfs.zip",
check_existing=True,
exp_ext=".tiff",
Expand Down Expand Up @@ -615,7 +613,7 @@ def test_is_expected_filetype_raises_multiple(self):
),
):
_is_expected_filetype(
"tests/data/gtfs/report/html_template.html",
"tests/data/report/html_template.html",
".html",
check_existing=True,
exp_ext=[".zip", ".gif", ".pdf"],
Expand All @@ -631,7 +629,7 @@ def test_is_expected_filetype_on_pass(self):
)
assert result is None
result = _is_expected_filetype(
"tests/data/gtfs/report/html_template.html",
"tests/data/report/html_template.html",
".html",
check_existing=True,
exp_ext=[".zip", ".gif", ".pbf", ".html"],
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_to_pickle_on_fail(
),
),
(
here("tests/data/gtfs/report/html_template.html"), # wrong ext
here("tests/data/report/html_template.html"), # wrong ext
pytest.raises(
ValueError,
match=re.escape(
Expand Down

0 comments on commit 8e28c4d

Please sign in to comment.