diff --git a/docs/source/differences-to-vws.rst b/docs/source/differences-to-vws.rst index a74b3befd..f80ff948e 100644 --- a/docs/source/differences-to-vws.rst +++ b/docs/source/differences-to-vws.rst @@ -398,6 +398,12 @@ Some malformed State-Based Model Target configuration documents remain mock-only Reco counts reports ------------------- +Vuforia documents ``POST /imagetargets/databases/{database_id}/reports/recoCounts``, and this endpoint previously worked against real Vuforia, so the mock continues to implement it. +The endpoint now returns an HTML 404 response for every database available to this project's test account, including a newly created database whose ID and server keys were read directly from the Target Manager. +This project treats that as a permanent limitation of its real-Vuforia test account. +The report tests therefore run against the mock backends only, including the cross-cutting authorization, date, content-length and JSON tests. +The mock remains useful for testing clients of the documented endpoint, but its behavior can no longer be compared continuously with the real service and may differ for accounts which can still use the endpoint. + The mock does not count recognitions, so a generated reco counts report contains only the ``target_id,reco_count`` header row, ending with a carriage return and a line feed, until recognition counts are set on targets. That is what real Vuforia returns for a database with no recognitions. diff --git a/tests/mock_vws/fixtures/vuforia_backends.py b/tests/mock_vws/fixtures/vuforia_backends.py index e7b8cefe4..f4370d6b1 100644 --- a/tests/mock_vws/fixtures/vuforia_backends.py +++ b/tests/mock_vws/fixtures/vuforia_backends.py @@ -421,6 +421,11 @@ class VuforiaBackend(Enum): "Real Vuforia can leave malformed-body requests open indefinitely; the " "mock backends still verify this contract." ) +_RECO_COUNTS_REAL_NODE_ID_PART = "[Real Vuforia-reco_counts_report" +_RECO_COUNTS_REAL_SKIP_REASON = ( + "The reco counts report endpoint is unavailable to the real-Vuforia " + "test account; the mock backends still verify this contract." +) @beartype @@ -453,9 +458,14 @@ def pytest_collection_modifyitems( invalid_json_real_marker = pytest.mark.skip( reason=_INVALID_JSON_REAL_SKIP_REASON, ) + reco_counts_real_marker = pytest.mark.skip( + reason=_RECO_COUNTS_REAL_SKIP_REASON, + ) for item in items: if item.nodeid.startswith(_INVALID_JSON_REAL_NODE_ID_PREFIXES): item.add_marker(marker=invalid_json_real_marker) + if _RECO_COUNTS_REAL_NODE_ID_PART in item.nodeid: + item.add_marker(marker=reco_counts_real_marker) @beartype diff --git a/tests/mock_vws/test_reco_counts_report.py b/tests/mock_vws/test_reco_counts_report.py index 530c502b7..468452d94 100644 --- a/tests/mock_vws/test_reco_counts_report.py +++ b/tests/mock_vws/test_reco_counts_report.py @@ -108,7 +108,7 @@ def _request_reco_counts_report( request_path=request_path, ) - response = requests.post( + return requests.post( url=_VWS_HOST + request_path, headers={ "Authorization": authorization_string, @@ -119,11 +119,6 @@ def _request_reco_counts_report( data=content, timeout=30, ) - if response.status_code == HTTPStatus.NOT_FOUND and response.headers.get( - "Content-Type", "" - ).startswith("text/html"): # pragma: no cover - pytest.skip(reason="The real reco counts endpoint is unavailable.") - return response @beartype @@ -211,7 +206,7 @@ def _wait_for_report(*, presigned_url: str) -> requests.Response: raise _ReportNotReadyError -@pytest.mark.usefixtures("verify_mock_vuforia") +@pytest.mark.usefixtures("mock_only_vuforia") class TestRecoCountsReport: """Tests for requesting a reco counts report.""" @@ -429,12 +424,12 @@ def test_database_name_in_path( ) -@pytest.mark.usefixtures("verify_mock_vuforia") +@pytest.mark.usefixtures("mock_only_vuforia") class TestDownloadReport: """Tests for downloading a generated reco counts report. - A real report has been observed ready within a second of being - requested, so these run against real Vuforia as well as the mocks. + The endpoint is unavailable to the real-Vuforia test account, so these + run against the mocks only. """ @staticmethod diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index 630145638..072bd212e 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -4,7 +4,6 @@ import secrets from collections.abc import Mapping from dataclasses import dataclass -from http import HTTPStatus from typing import Literal from urllib.parse import urljoin @@ -104,23 +103,12 @@ class Endpoint: @beartype def send(self) -> Response: """Send the request.""" - url = urljoin(base=self.base_url, url=self.path_url) - response = _send_request( + return _send_request( method=self.method, - url=url, + url=urljoin(base=self.base_url, url=self.path_url), headers=self.headers, data=self.data, ) - if ( - url.startswith("https://vws.vuforia.com/imagetargets/databases/") - and url.endswith("/reports/recoCounts") - and response.status_code == HTTPStatus.NOT_FOUND - and response.headers.get("Content-Type", "").startswith( - "text/html", - ) - ): # pragma: no cover - pytest.skip(reason="The real reco counts endpoint is unavailable.") - return response @property def auth_header_content_type(self) -> str: