Skip to content

Commit

Permalink
Skip tests until we can use GCS on Github Actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikamov committed Nov 15, 2024
1 parent 7134bda commit 6edb9a0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
7 changes: 7 additions & 0 deletions jobs/gtfs-rt-parser-v2/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def pytest_addoption(parser):
parser.addoption(
"--gcs",
action="store_true",
default=False,
help="Run tests requiring GCS",
)
2 changes: 1 addition & 1 deletion jobs/gtfs-rt-parser-v2/gtfs_rt_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def validate_and_upload(
with open(results_path) as f:
records = json.load(f)
except FileNotFoundError as e:
# TODO: does this mean no errors?
# This exception was previously generating the error "[Errno 2] No such file or directory"
msg = f"WARNING: no validation output file found in {results_path} for {extract.path}"
if verbose:
log(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ def test_rt_file_processing_outcome_construction() -> None:
)


@pytest.mark.skipif("not config.getoption('--gcs')", reason="requires GCS credentials")
def test_vehicle_positions():
base64url = "aHR0cHM6Ly9tdnNodXR0bGUucmlkZXN5c3RlbXMubmV0L3N1YnNjcmlwdGlvbnMvZ3Rmc3J0L3ZlaGljbGVzLmFzaHg="
result = runner.invoke(
app,
["parse", "vehicle_positions", "2024-10-22T18:00:00", "--base64url", base64url],
["parse", "vehicle_positions", "1999-10-22T18:00:00"],
catch_exceptions=False,
)
assert result.exit_code == 0
assert (
"test-calitp-gtfs-rt-raw-v2/vehicle_positions/dt=2024-10-22/hour=2024-10-22T18:00:00+00:00"
"test-calitp-gtfs-rt-raw-v2/vehicle_positions/dt=1999-10-22/hour=1999-10-22T18:00:00+00:00"
in result.stdout
)
assert "4786 vehicle_positions files in 139 aggregations" in result.stdout
assert "1 vehicle_positions files in 1 aggregations" in result.stdout

assert f"url filter applied, only processing {base64url}" in result.stdout
assert "writing 28 lines" in result.stdout
assert "writing 1 lines" in result.stdout
assert "test-calitp-gtfs-rt-parsed" in result.stdout
assert "saving 40 outcomes" in result.stdout
assert "saving 1 outcomes" in result.stdout


@pytest.mark.skipif("not config.getoption('--gcs')", reason="requires GCS credentials")
def test_no_vehicle_positions_for_date():
base64url = (
"aHR0cHM6Ly9hcGkuNTExLm9yZy90cmFuc2l0L3ZlaGljbGVwb3NpdGlvbnM_YWdlbmN5PVNJ"
Expand All @@ -87,6 +87,7 @@ def test_no_vehicle_positions_for_date():
assert "outcomes" not in result.stdout


@pytest.mark.skipif("not config.getoption('--gcs')", reason="requires GCS credentials")
def test_no_vehicle_positions_for_url():
result = runner.invoke(
app,
Expand All @@ -99,6 +100,7 @@ def test_no_vehicle_positions_for_url():
assert "outcomes" not in result.stdout


@pytest.mark.skipif("not config.getoption('--gcs')", reason="requires GCS credentials")
def test_no_records_for_url_vehicle_positions_on_date():
base64url = (
"aHR0cHM6Ly9hcGkuNTExLm9yZy90cmFuc2l0L3ZlaGljbGVwb3NpdGlvbnM_YWdlbmN5PVNJ"
Expand All @@ -115,6 +117,7 @@ def test_no_records_for_url_vehicle_positions_on_date():
assert "saving 38 outcomes" in result.stdout


@pytest.mark.skipif("not config.getoption('--gcs')", reason="requires GCS credentials")
def test_trip_updates():
base64url = "aHR0cHM6Ly9hcGkuNTExLm9yZy90cmFuc2l0L3RyaXB1cGRhdGVzP2FnZW5jeT1TQQ=="
result = runner.invoke(
Expand All @@ -135,6 +138,7 @@ def test_trip_updates():
assert "saving 49 outcomes" in result.stdout


@pytest.mark.skipif("not config.getoption('--gcs')", reason="requires GCS credentials")
def test_service_alerts():
base64url = "aHR0cHM6Ly9hcGkuNTExLm9yZy90cmFuc2l0L3NlcnZpY2VhbGVydHM_YWdlbmN5PUFN"
result = runner.invoke(
Expand All @@ -155,6 +159,7 @@ def test_service_alerts():
assert "saving 30 outcomes" in result.stdout


@pytest.mark.skipif("not config.getoption('--gcs')", reason="requires GCS credentials")
def test_validation():
base64url = "aHR0cHM6Ly9hcGkuZ29zd2lmdC5seS9yZWFsLXRpbWUvbWVuZG9jaW5vL2d0ZnMtcnQtdHJpcC11cGRhdGVz"
result = runner.invoke(
Expand All @@ -175,6 +180,7 @@ def test_validation():
assert "saving 30 outcomes" in result.stdout


@pytest.mark.skipif("not config.getoption('--gcs')", reason="requires GCS credentials")
def test_no_recent_schedule_for_vehicle_positions_on_validation():
base64url = (
"aHR0cHM6Ly9hcGkuNTExLm9yZy90cmFuc2l0L3ZlaGljbGVwb3NpdGlvbnM_YWdlbmN5PVNJ"
Expand Down Expand Up @@ -202,8 +208,8 @@ def test_no_recent_schedule_for_vehicle_positions_on_validation():
assert "saving 38 outcomes" in result.stdout


@pytest.mark.skipif("not config.getoption('--gcs')", reason="requires GCS credentials")
def test_no_output_file_for_vehicle_positions_on_validation():
# "WARNING: no validation output file found" generates the log "[Errno 2] No such file or directory"
result = runner.invoke(
app,
[
Expand All @@ -216,12 +222,14 @@ def test_no_output_file_for_vehicle_positions_on_validation():
],
catch_exceptions=True,
)
print(result.stdout)
assert result.exit_code == 0
assert (
"test-calitp-gtfs-rt-raw-v2/vehicle_positions/dt=2024-10-17/hour=2024-10-17T00:00:00+00:00"
in result.stdout
)
assert "5487 vehicle_positions files in 139 aggregations" in result.stdout
assert "limit of 3 feeds was set" in result.stdout
# "WARNING: no validation output file found" was previously generating the error "[Errno 2] No such file or directory"
assert "WARNING: no validation output file found" in result.stdout
assert "saving 122 outcomes" in result.stdout

0 comments on commit 6edb9a0

Please sign in to comment.