Skip to content

Commit 73e6d9f

Browse files
Separate report timing coverage from the shared suite (#3757)
1 parent 08cb783 commit 73e6d9f

2 files changed

Lines changed: 59 additions & 45 deletions

File tree

‎tests/mock_vws/reco_counts_report/test_download_report_mock_only.py‎

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@
66
a URL for its storage.
77
"""
88

9-
import datetime
109
import io
1110
import uuid
12-
from http import HTTPStatus
1311
from urllib.parse import urlsplit, urlunsplit
1412

1513
import pytest
1614
import requests
17-
from beartype import BeartypeConf, beartype
18-
from freezegun import freeze_time
1915

20-
from mock_vws import MockVWS
2116
from mock_vws.database import CloudDatabase
2217
from tests.mock_vws.reco_counts_report.helpers import (
2318
CSV_HEADER,
@@ -183,43 +178,3 @@ def test_counts_set_after_first_request(
183178
# new file, and nothing is claimed about that.
184179
same_file = urlsplit(url=first_url).path == urlsplit(url=second_url).path
185180
assert not same_file or ready_response.text == CSV_HEADER
186-
187-
188-
@pytest.mark.parametrize(
189-
argnames="processing_time_seconds",
190-
argvalues=[
191-
pytest.param(60, id="integer"),
192-
pytest.param(60.0, id="float"),
193-
pytest.param(0.5, id="fractional"),
194-
],
195-
)
196-
@beartype(conf=BeartypeConf(is_pep484_tower=True))
197-
def test_report_processing_time(
198-
*, base_vws_url: str, processing_time_seconds: float
199-
) -> None:
200-
"""Integer and float delays make reports ready at their completion
201-
time.
202-
"""
203-
database = CloudDatabase()
204-
with (
205-
freeze_time(time_to_freeze="2026-10-13 12:00:00") as frozen_time,
206-
MockVWS(
207-
base_vws_url=base_vws_url,
208-
processing_time_seconds=processing_time_seconds,
209-
) as mock,
210-
):
211-
mock.add_cloud_database(cloud_database=database)
212-
presigned_url = get_presigned_url(
213-
base_vws_url=base_vws_url,
214-
vuforia_database=database,
215-
month=month_offset_from_now(months=0),
216-
)
217-
response = requests.get(url=presigned_url, timeout=30)
218-
assert_not_ready(response=response, key=report_key(url=presigned_url))
219-
220-
_ = frozen_time.tick(
221-
delta=datetime.timedelta(seconds=processing_time_seconds),
222-
)
223-
response = requests.get(url=presigned_url, timeout=30)
224-
assert response.status_code == HTTPStatus.OK
225-
assert response.text == CSV_HEADER
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""Tests for report timing in the in-memory mock."""
2+
3+
import datetime
4+
from http import HTTPStatus
5+
6+
import pytest
7+
import requests
8+
from beartype import BeartypeConf, beartype
9+
from freezegun import freeze_time
10+
11+
from mock_vws import MockVWS
12+
from mock_vws.database import CloudDatabase
13+
from tests.mock_vws.reco_counts_report.helpers import (
14+
CSV_HEADER,
15+
assert_not_ready,
16+
get_presigned_url,
17+
month_offset_from_now,
18+
report_key,
19+
)
20+
21+
22+
@pytest.mark.parametrize(
23+
argnames="processing_time_seconds",
24+
argvalues=[
25+
pytest.param(60, id="integer"),
26+
pytest.param(60.0, id="float"),
27+
pytest.param(0.5, id="fractional"),
28+
],
29+
)
30+
@beartype(conf=BeartypeConf(is_pep484_tower=True))
31+
def test_report_processing_time(
32+
*, base_vws_url: str, processing_time_seconds: float
33+
) -> None:
34+
"""Integer and float delays make reports ready at their completion
35+
time.
36+
"""
37+
database = CloudDatabase()
38+
with (
39+
freeze_time(time_to_freeze="2026-10-13 12:00:00") as frozen_time,
40+
MockVWS(
41+
base_vws_url=base_vws_url,
42+
processing_time_seconds=processing_time_seconds,
43+
) as mock,
44+
):
45+
mock.add_cloud_database(cloud_database=database)
46+
presigned_url = get_presigned_url(
47+
base_vws_url=base_vws_url,
48+
vuforia_database=database,
49+
month=month_offset_from_now(months=0),
50+
)
51+
response = requests.get(url=presigned_url, timeout=30)
52+
assert_not_ready(response=response, key=report_key(url=presigned_url))
53+
54+
_ = frozen_time.tick(
55+
delta=datetime.timedelta(seconds=processing_time_seconds),
56+
)
57+
response = requests.get(url=presigned_url, timeout=30)
58+
assert response.status_code == HTTPStatus.OK
59+
assert response.text == CSV_HEADER

0 commit comments

Comments
 (0)