diff --git a/tests/mock_vws/authorization_header/test_authorization_header.py b/tests/mock_vws/authorization_header/test_authorization_header.py index 6433b85cf..c041e1ac3 100644 --- a/tests/mock_vws/authorization_header/test_authorization_header.py +++ b/tests/mock_vws/authorization_header/test_authorization_header.py @@ -4,7 +4,6 @@ """ from http import HTTPStatus -from urllib.parse import urlparse from vws_auth_tools import rfc_1123_date @@ -17,7 +16,7 @@ from tests.mock_vws.utils.too_many_requests import handle_server_errors -def test_missing(endpoint: Endpoint) -> None: +def test_missing(endpoint: Endpoint, base_vwq_url: str) -> None: """ An `UNAUTHORIZED` response is returned when no `Authorization` header @@ -46,8 +45,7 @@ def test_missing(endpoint: Endpoint) -> None: handle_server_errors(response=response) - netloc = urlparse(url=endpoint.base_url).netloc - if netloc == "cloudreco.vuforia.com": + if endpoint.base_url == base_vwq_url: assert_vwq_failure( response=response, status_code=HTTPStatus.UNAUTHORIZED, diff --git a/tests/mock_vws/date_header/test_missing.py b/tests/mock_vws/date_header/test_missing.py index bfef5f907..5bc75e658 100644 --- a/tests/mock_vws/date_header/test_missing.py +++ b/tests/mock_vws/date_header/test_missing.py @@ -1,7 +1,6 @@ """Tests for what happens when the `Date` header is missing.""" from http import HTTPStatus -from urllib.parse import urlparse from vws_auth_tools import authorization_header @@ -14,7 +13,7 @@ from tests.mock_vws.utils.too_many_requests import handle_server_errors -def test_no_date_header(endpoint: Endpoint) -> None: +def test_no_date_header(endpoint: Endpoint, base_vwq_url: str) -> None: """ A `BAD_REQUEST` response is returned when no `Date` header is given. @@ -51,9 +50,7 @@ def test_no_date_header(endpoint: Endpoint) -> None: handle_server_errors(response=response) - netloc = urlparse(url=endpoint.base_url).netloc - - if netloc == "cloudreco.vuforia.com": + if endpoint.base_url == base_vwq_url: expected_content_type = "text/plain;charset=iso-8859-1" assert response.text == "Date header required." assert_vwq_failure( diff --git a/tests/mock_vws/fixtures/prepared_requests.py b/tests/mock_vws/fixtures/prepared_requests.py index 0201fdec7..e9ff85951 100644 --- a/tests/mock_vws/fixtures/prepared_requests.py +++ b/tests/mock_vws/fixtures/prepared_requests.py @@ -17,14 +17,12 @@ from tests.mock_vws.fixtures.credentials import VuMarkCloudDatabase from tests.mock_vws.utils import Endpoint -VWS_HOST = "https://vws.vuforia.com" -VWQ_HOST = "https://cloudreco.vuforia.com" - @pytest.fixture def add_target( *, vuforia_database: CloudDatabase, + base_vws_url: str, image_file_failed_state: io.BytesIO, ) -> Endpoint: """Return details of the endpoint for adding a target.""" @@ -66,7 +64,7 @@ def add_target( return Endpoint( successful_headers_status_code=HTTPStatus.CREATED, successful_headers_result_code=ResultCodes.TARGET_CREATED, - base_url=VWS_HOST, + base_url=base_vws_url, path_url=request_path, method=method, headers=headers, @@ -80,6 +78,7 @@ def add_target( def delete_target( *, vuforia_database: CloudDatabase, + base_vws_url: str, target_id: str, ) -> Endpoint: """Return details of the endpoint for deleting a target.""" @@ -107,7 +106,7 @@ def delete_target( } return Endpoint( - base_url=VWS_HOST, + base_url=base_vws_url, path_url=request_path, method=method, headers=headers, @@ -120,7 +119,11 @@ def delete_target( @pytest.fixture -def database_summary(*, vuforia_database: CloudDatabase) -> Endpoint: +def database_summary( + *, + vuforia_database: CloudDatabase, + base_vws_url: str, +) -> Endpoint: """ Return details of the endpoint for getting details about the database. @@ -150,7 +153,7 @@ def database_summary(*, vuforia_database: CloudDatabase) -> Endpoint: } return Endpoint( - base_url=VWS_HOST, + base_url=base_vws_url, path_url=request_path, method=method, headers=headers, @@ -166,6 +169,7 @@ def database_summary(*, vuforia_database: CloudDatabase) -> Endpoint: def get_duplicates( *, vuforia_database: CloudDatabase, + base_vws_url: str, target_id: str, ) -> Endpoint: """ @@ -197,7 +201,7 @@ def get_duplicates( } return Endpoint( - base_url=VWS_HOST, + base_url=base_vws_url, path_url=request_path, method=method, headers=headers, @@ -213,6 +217,7 @@ def get_duplicates( def get_target( *, vuforia_database: CloudDatabase, + base_vws_url: str, target_id: str, ) -> Endpoint: """Return details of the endpoint for getting details of a target.""" @@ -243,7 +248,7 @@ def get_target( return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - base_url=VWS_HOST, + base_url=base_vws_url, path_url=request_path, method=method, headers=headers, @@ -254,7 +259,11 @@ def get_target( @pytest.fixture -def target_list(*, vuforia_database: CloudDatabase) -> Endpoint: +def target_list( + *, + vuforia_database: CloudDatabase, + base_vws_url: str, +) -> Endpoint: """Return details of the endpoint for getting a list of targets.""" date = rfc_1123_date() request_path = "/targets" @@ -283,7 +292,7 @@ def target_list(*, vuforia_database: CloudDatabase) -> Endpoint: return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - base_url=VWS_HOST, + base_url=base_vws_url, path_url=request_path, method=method, headers=headers, @@ -297,6 +306,7 @@ def target_list(*, vuforia_database: CloudDatabase) -> Endpoint: def target_summary( *, vuforia_database: CloudDatabase, + base_vws_url: str, target_id: str, ) -> Endpoint: """ @@ -330,7 +340,7 @@ def target_summary( return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - base_url=VWS_HOST, + base_url=base_vws_url, path_url=request_path, method=method, headers=headers, @@ -344,6 +354,7 @@ def target_summary( def update_target( *, vuforia_database: CloudDatabase, + base_vws_url: str, target_id: str, ) -> Endpoint: """Return details of the endpoint for updating a target.""" @@ -377,7 +388,7 @@ def update_target( return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - base_url=VWS_HOST, + base_url=base_vws_url, path_url=request_path, method=method, headers=headers, @@ -391,6 +402,7 @@ def update_target( def query( *, vuforia_database: CloudDatabase, + base_vwq_url: str, high_quality_image: io.BytesIO, ) -> Endpoint: """ @@ -428,7 +440,7 @@ def query( return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - base_url=VWQ_HOST, + base_url=base_vwq_url, path_url=request_path, method=method, headers=headers, @@ -442,6 +454,7 @@ def query( def vumark_generate_instance( *, vumark_vuforia_database: VuMarkCloudDatabase, + base_vws_url: str, ) -> Endpoint: """Return details of the endpoint for generating a VuMark instance.""" request_path = f"/targets/{vumark_vuforia_database.target_id}/instances" @@ -475,7 +488,7 @@ def vumark_generate_instance( return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=None, - base_url=VWS_HOST, + base_url=base_vws_url, path_url=request_path, method=method, headers=headers, @@ -486,7 +499,11 @@ def vumark_generate_instance( @pytest.fixture -def reco_counts_report(*, vuforia_database: CloudDatabase) -> Endpoint: +def reco_counts_report( + *, + vuforia_database: CloudDatabase, + base_vws_url: str, +) -> Endpoint: """Return details of the endpoint for requesting a reco counts report. """ @@ -521,7 +538,7 @@ def reco_counts_report(*, vuforia_database: CloudDatabase) -> Endpoint: return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - base_url=VWS_HOST, + base_url=base_vws_url, path_url=request_path, method=method, headers=headers,