From ee1fbbb7ed9dcc65b0ef944d20515f5b6b7f3241 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 13 Oct 2026 22:57:11 +0100 Subject: [PATCH] Separate report timing coverage from the shared suite --- .../test_download_report_mock_only.py | 45 -------------- .../requests_mock/test_reco_counts_report.py | 59 +++++++++++++++++++ 2 files changed, 59 insertions(+), 45 deletions(-) create mode 100644 tests/mock_vws/requests_mock/test_reco_counts_report.py diff --git a/tests/mock_vws/reco_counts_report/test_download_report_mock_only.py b/tests/mock_vws/reco_counts_report/test_download_report_mock_only.py index 530a3afd7..94d74d274 100644 --- a/tests/mock_vws/reco_counts_report/test_download_report_mock_only.py +++ b/tests/mock_vws/reco_counts_report/test_download_report_mock_only.py @@ -6,18 +6,13 @@ a URL for its storage. """ -import datetime import io import uuid -from http import HTTPStatus from urllib.parse import urlsplit, urlunsplit import pytest import requests -from beartype import BeartypeConf, beartype -from freezegun import freeze_time -from mock_vws import MockVWS from mock_vws.database import CloudDatabase from tests.mock_vws.reco_counts_report.helpers import ( CSV_HEADER, @@ -183,43 +178,3 @@ def test_counts_set_after_first_request( # new file, and nothing is claimed about that. same_file = urlsplit(url=first_url).path == urlsplit(url=second_url).path assert not same_file or ready_response.text == CSV_HEADER - - -@pytest.mark.parametrize( - argnames="processing_time_seconds", - argvalues=[ - pytest.param(60, id="integer"), - pytest.param(60.0, id="float"), - pytest.param(0.5, id="fractional"), - ], -) -@beartype(conf=BeartypeConf(is_pep484_tower=True)) -def test_report_processing_time( - *, base_vws_url: str, processing_time_seconds: float -) -> None: - """Integer and float delays make reports ready at their completion - time. - """ - database = CloudDatabase() - with ( - freeze_time(time_to_freeze="2026-10-13 12:00:00") as frozen_time, - MockVWS( - base_vws_url=base_vws_url, - processing_time_seconds=processing_time_seconds, - ) as mock, - ): - mock.add_cloud_database(cloud_database=database) - presigned_url = get_presigned_url( - base_vws_url=base_vws_url, - vuforia_database=database, - month=month_offset_from_now(months=0), - ) - response = requests.get(url=presigned_url, timeout=30) - assert_not_ready(response=response, key=report_key(url=presigned_url)) - - _ = frozen_time.tick( - delta=datetime.timedelta(seconds=processing_time_seconds), - ) - response = requests.get(url=presigned_url, timeout=30) - assert response.status_code == HTTPStatus.OK - assert response.text == CSV_HEADER diff --git a/tests/mock_vws/requests_mock/test_reco_counts_report.py b/tests/mock_vws/requests_mock/test_reco_counts_report.py new file mode 100644 index 000000000..f82627104 --- /dev/null +++ b/tests/mock_vws/requests_mock/test_reco_counts_report.py @@ -0,0 +1,59 @@ +"""Tests for report timing in the in-memory mock.""" + +import datetime +from http import HTTPStatus + +import pytest +import requests +from beartype import BeartypeConf, beartype +from freezegun import freeze_time + +from mock_vws import MockVWS +from mock_vws.database import CloudDatabase +from tests.mock_vws.reco_counts_report.helpers import ( + CSV_HEADER, + assert_not_ready, + get_presigned_url, + month_offset_from_now, + report_key, +) + + +@pytest.mark.parametrize( + argnames="processing_time_seconds", + argvalues=[ + pytest.param(60, id="integer"), + pytest.param(60.0, id="float"), + pytest.param(0.5, id="fractional"), + ], +) +@beartype(conf=BeartypeConf(is_pep484_tower=True)) +def test_report_processing_time( + *, base_vws_url: str, processing_time_seconds: float +) -> None: + """Integer and float delays make reports ready at their completion + time. + """ + database = CloudDatabase() + with ( + freeze_time(time_to_freeze="2026-10-13 12:00:00") as frozen_time, + MockVWS( + base_vws_url=base_vws_url, + processing_time_seconds=processing_time_seconds, + ) as mock, + ): + mock.add_cloud_database(cloud_database=database) + presigned_url = get_presigned_url( + base_vws_url=base_vws_url, + vuforia_database=database, + month=month_offset_from_now(months=0), + ) + response = requests.get(url=presigned_url, timeout=30) + assert_not_ready(response=response, key=report_key(url=presigned_url)) + + _ = frozen_time.tick( + delta=datetime.timedelta(seconds=processing_time_seconds), + ) + response = requests.get(url=presigned_url, timeout=30) + assert response.status_code == HTTPStatus.OK + assert response.text == CSV_HEADER