diff --git a/tests/development/authentication/__init__.py b/tests/development/message_batches/__init__.py similarity index 100% rename from tests/development/authentication/__init__.py rename to tests/development/message_batches/__init__.py diff --git a/tests/development/content_types/__init__.py b/tests/development/message_batches/authentication/__init__.py similarity index 100% rename from tests/development/content_types/__init__.py rename to tests/development/message_batches/authentication/__init__.py diff --git a/tests/development/authentication/test_401_errors.py b/tests/development/message_batches/authentication/test_401_errors.py similarity index 82% rename from tests/development/authentication/test_401_errors.py rename to tests/development/message_batches/authentication/test_401_errors.py index a00a32bee..008fb6baa 100644 --- a/tests/development/authentication/test_401_errors.py +++ b/tests/development/message_batches/authentication/test_401_errors.py @@ -2,6 +2,7 @@ import pytest from lib import Assertions, Generators from lib.constants.constants import CORRELATION_IDS, METHODS, TOKENS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT @pytest.mark.devtest @@ -12,7 +13,7 @@ def test_401_invalid_level(nhsd_apim_proxy_url, nhsd_apim_auth_headers, correlat """ .. include:: ../../partials/authentication/test_401_invalid_level.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "X-Correlation-Id": correlation_id }) @@ -33,7 +34,7 @@ def test_401_invalid(nhsd_apim_proxy_url, invalid_token, correlation_id, method) """ .. include:: ../../partials/authentication/test_401_invalid.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": invalid_token, "X-Correlation-Id": correlation_id }) diff --git a/tests/development/authentication/test_403_errors.py b/tests/development/message_batches/authentication/test_403_errors.py similarity index 83% rename from tests/development/authentication/test_403_errors.py rename to tests/development/message_batches/authentication/test_403_errors.py index 80d30cdf5..2316e9c5e 100644 --- a/tests/development/authentication/test_403_errors.py +++ b/tests/development/message_batches/authentication/test_403_errors.py @@ -1,8 +1,8 @@ import requests import pytest from lib import Assertions, Generators +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT -REQUEST_PATH = "/v1/message-batches" METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] CORRELATION_IDS = [None, "76491414-d0cf-4655-ae20-a4d1368472f3"] @@ -21,7 +21,7 @@ def test_user_token_get(nhsd_apim_proxy_url, nhsd_apim_auth_headers, correlation """ .. include:: ../../partials/authentication/test_user_token_get.rst """ - resp = requests.get(f"{nhsd_apim_proxy_url}{REQUEST_PATH}", headers={ + resp = requests.get(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "X-Correlation-Id": correlation_id }) diff --git a/tests/development/create_message_batches/__init__.py b/tests/development/message_batches/content_types/__init__.py similarity index 100% rename from tests/development/create_message_batches/__init__.py rename to tests/development/message_batches/content_types/__init__.py diff --git a/tests/development/content_types/test_406_errors.py b/tests/development/message_batches/content_types/test_406_errors.py similarity index 87% rename from tests/development/content_types/test_406_errors.py rename to tests/development/message_batches/content_types/test_406_errors.py index ff6166759..fd4243e0a 100644 --- a/tests/development/content_types/test_406_errors.py +++ b/tests/development/message_batches/content_types/test_406_errors.py @@ -2,10 +2,10 @@ import pytest from lib import Assertions, Generators from lib.constants.constants import DEFAULT_CONTENT_TYPE +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT HEADER_NAME = ["accept", "ACCEPT", "Accept", "AcCePt"] HEADER_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] -REQUEST_PATH = ["/v1/ignore", "/api/ignore"] METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] CORRELATION_IDS = [None, "88b10816-5d45-4992-bed0-ea685aaa0e1f"] @@ -13,7 +13,6 @@ @pytest.mark.devtest @pytest.mark.parametrize("accept_header_name", HEADER_NAME) @pytest.mark.parametrize("accept_header_value", HEADER_VALUE) -@pytest.mark.parametrize("request_path", REQUEST_PATH) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) @pytest.mark.nhsd_apim_authorization({"access": "application", "level": "level3"}) @@ -21,7 +20,6 @@ def test_406( nhsd_apim_proxy_url, accept_header_name, accept_header_value, - request_path, correlation_id, method, nhsd_apim_auth_headers @@ -29,7 +27,7 @@ def test_406( """ .. include:: ../../partials/content_types/test_406.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}/{request_path}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}/{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, accept_header_name: accept_header_value, "X-Correlation-Id": correlation_id diff --git a/tests/development/content_types/test_415_errors.py b/tests/development/message_batches/content_types/test_415_errors.py similarity index 86% rename from tests/development/content_types/test_415_errors.py rename to tests/development/message_batches/content_types/test_415_errors.py index 03727498e..6eacfd19b 100644 --- a/tests/development/content_types/test_415_errors.py +++ b/tests/development/message_batches/content_types/test_415_errors.py @@ -1,10 +1,10 @@ import requests import pytest from lib import Assertions, Generators +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT CONTENT_TYPE_NAME = ["content-type", "CONTENT_TYPE", "Content_Type", "conTENT_tYpe"] CONTENT_TYPE_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] -REQUEST_PATH = ["/v1/ignore", "/api/ignore"] METHODS = ["post", "put", "patch"] CORRELATION_IDS = [None, "88b10816-5d45-4992-bed0-ea685aaa0e1f"] @@ -12,7 +12,6 @@ @pytest.mark.devtest @pytest.mark.parametrize("content_type_name", CONTENT_TYPE_NAME) @pytest.mark.parametrize("content_type_value", CONTENT_TYPE_VALUE) -@pytest.mark.parametrize("request_path", REQUEST_PATH) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) @pytest.mark.nhsd_apim_authorization({"access": "application", "level": "level3"}) @@ -20,7 +19,6 @@ def test_415_invalid( nhsd_apim_proxy_url, content_type_name, content_type_value, - request_path, correlation_id, method, nhsd_apim_auth_headers @@ -28,7 +26,7 @@ def test_415_invalid( """ .. include:: ../../partials/content_types/test_415_invalid.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{request_path}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "Accept": "application/json", content_type_name: content_type_value, diff --git a/tests/development/content_types/test_content_type_negotiation.py b/tests/development/message_batches/content_types/test_content_type_negotiation.py similarity index 86% rename from tests/development/content_types/test_content_type_negotiation.py rename to tests/development/message_batches/content_types/test_content_type_negotiation.py index 3f469b9fa..02f52a1fc 100644 --- a/tests/development/content_types/test_content_type_negotiation.py +++ b/tests/development/message_batches/content_types/test_content_type_negotiation.py @@ -1,6 +1,7 @@ import requests import pytest from lib.constants.constants import METHODS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT from lib import Error_Handler DEFAULT_CONTENT_TYPE = "application/vnd.api+json" @@ -34,7 +35,7 @@ def test_application_response_type(nhsd_apim_proxy_url, accept_headers, method, """ .. include:: ../../partials/content_types/test_application_response_type.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **accept_headers.get("headers") }) diff --git a/tests/development/content_types/test_missing_accept_header.py b/tests/development/message_batches/content_types/test_missing_accept_header.py similarity index 89% rename from tests/development/content_types/test_missing_accept_header.py rename to tests/development/message_batches/content_types/test_missing_accept_header.py index 81c2e971b..071c58c9c 100644 --- a/tests/development/content_types/test_missing_accept_header.py +++ b/tests/development/message_batches/content_types/test_missing_accept_header.py @@ -1,8 +1,8 @@ import requests import pytest from lib import Assertions, Generators, Error_Handler +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT -REQUEST_PATH = "/v1/message-batches" CORRELATION_IDS = [None, "88b10816-5d45-4992-bed0-ea685aaa0e1f"] VALID_CONTENT_TYPE_HEADERS = ["application/json", "application/vnd.api+json"] @@ -23,7 +23,7 @@ def test_missing_accept_header( data = Generators.generate_valid_create_message_batch_body("dev") resp = requests.post( - f"{nhsd_apim_proxy_url}{REQUEST_PATH}", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Content-Type": content_type, "X-Correlation-Id": correlation_id, diff --git a/tests/development/headers/__init__.py b/tests/development/message_batches/create_message_batches/__init__.py similarity index 100% rename from tests/development/headers/__init__.py rename to tests/development/message_batches/create_message_batches/__init__.py diff --git a/tests/development/create_message_batches/test_field_validation.py b/tests/development/message_batches/create_message_batches/test_field_validation.py similarity index 91% rename from tests/development/create_message_batches/test_field_validation.py rename to tests/development/message_batches/create_message_batches/test_field_validation.py index 8ed78a5d3..1f2ebb346 100644 --- a/tests/development/create_message_batches/test_field_validation.py +++ b/tests/development/message_batches/create_message_batches/test_field_validation.py @@ -4,7 +4,9 @@ from lib import Assertions, Permutations, Generators import lib.constants.constants as constants from lib.constants.shared_paths import ROUTING_PLAN_ID_PATH -from lib.constants.message_batches_paths import * +from lib.constants.message_batches_paths import MISSING_PROPERTIES_PATHS, NULL_PROPERTIES_PATHS, \ + INVALID_PROPERTIES_PATHS, DUPLICATE_PROPERTIES_PATHS, TOO_FEW_PROPERTIES_PATHS, MESSAGE_BATCH_REFERENCE_PATH, \ + FIRST_MESSAGE_RECIPIENT_NHSNUMBER_PATH, FIRST_MESSAGE_REFERENCE_PATH, MESSAGE_BATCHES_ENDPOINT headers = { "Accept": "application/json", @@ -20,7 +22,7 @@ def test_invalid_body(nhsd_apim_proxy_url, correlation_id, nhsd_apim_auth_header .. include:: ../../partials/validation/test_invalid_body.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, @@ -49,7 +51,7 @@ def test_property_missing(nhsd_apim_proxy_url, property, pointer, correlation_id .. include:: ../../partials/validation/test_property_missing.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, @@ -81,7 +83,7 @@ def test_data_null(nhsd_apim_proxy_url, property, pointer, correlation_id, nhsd_ .. include:: ../../partials/validation/test_data_null.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, @@ -113,7 +115,7 @@ def test_data_invalid(nhsd_apim_proxy_url, property, pointer, correlation_id, nh .. include:: ../../partials/validation/test_data_invalid.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, @@ -151,7 +153,7 @@ def test_data_duplicate(nhsd_apim_proxy_url, property, pointer, correlation_id, # Post the same message a 2nd time to trigger the duplicate error resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, @@ -180,7 +182,7 @@ def test_data_too_few_items(nhsd_apim_proxy_url, property, pointer, correlation_ .. include:: ../../partials/validation/test_data_too_few_items.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, @@ -209,7 +211,7 @@ def test_invalid_nhs_number(nhsd_apim_proxy_url, nhs_number, correlation_id, nhs """ .. include:: ../../partials/validation/test_invalid_nhs_number.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, "X-Correlation-Id": correlation_id @@ -248,7 +250,7 @@ def test_invalid_dob(nhsd_apim_proxy_url, dob, correlation_id, nhsd_apim_auth_he """ .. include:: ../../partials/validation/test_invalid_dob.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, "X-Correlation-Id": correlation_id @@ -287,7 +289,7 @@ def test_invalid_routing_plan(nhsd_apim_proxy_url, correlation_id, nhsd_apim_aut """ .. include:: ../../partials/validation/test_invalid_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, "X-Correlation-Id": correlation_id @@ -326,7 +328,7 @@ def test_invalid_message_batch_reference(nhsd_apim_proxy_url, correlation_id, nh """ .. include:: ../../partials/validation/test_invalid_message_batch_reference.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, "X-Correlation-Id": correlation_id @@ -365,7 +367,7 @@ def test_invalid_message_reference(nhsd_apim_proxy_url, correlation_id, nhsd_api """ .. include:: ../../partials/validation/test_invalid_message_reference.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, "X-Correlation-Id": correlation_id @@ -405,7 +407,7 @@ def test_blank_value_under_messages(nhsd_apim_proxy_url, invalid_value, correlat """ .. include:: ../../partials/validation/test_blank_value_under_messages.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, "X-Correlation-Id": correlation_id @@ -437,7 +439,7 @@ def test_null_value_under_messages(nhsd_apim_proxy_url, correlation_id, nhsd_api """ .. include:: ../../partials/validation/test_null_value_under_messages.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, **headers, "X-Correlation-Id": correlation_id diff --git a/tests/development/create_message_batches/test_invalid_routing_plan.py b/tests/development/message_batches/create_message_batches/test_invalid_routing_plan.py similarity index 93% rename from tests/development/create_message_batches/test_invalid_routing_plan.py rename to tests/development/message_batches/create_message_batches/test_invalid_routing_plan.py index 3fbd993fa..ed40870db 100644 --- a/tests/development/create_message_batches/test_invalid_routing_plan.py +++ b/tests/development/message_batches/create_message_batches/test_invalid_routing_plan.py @@ -2,6 +2,7 @@ import pytest import uuid from lib import Assertions, Generators +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT CORRELATION_IDS = [None, "228aac39-542d-4803-b28e-5de9e100b9f8"] METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] @@ -16,7 +17,7 @@ def test_no_such_routing_plan(nhsd_apim_proxy_url, correlation_id, nhsd_apim_aut """ .. include:: ../../partials/invalid_routing_plans/test_no_such_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "X-Correlation-Id": correlation_id }, json={ @@ -54,7 +55,7 @@ def test_routing_plan_not_belonging_to_client_id(nhsd_apim_proxy_url, correlatio """ .. include:: ../../partials/invalid_routing_plans/test_routing_plan_not_belonging_to_client_id.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "X-Correlation-Id": correlation_id }, json={ @@ -92,7 +93,7 @@ def test_500_duplicate_routing_plan(nhsd_apim_proxy_url, correlation_id, nhsd_ap """ .. include:: ../../partials/invalid_routing_plans/test_500_duplicate_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "X-Correlation-Id": correlation_id }, json={ @@ -146,7 +147,7 @@ def test_routing_plan_missing_templates( """ .. include:: ../../partials/invalid_routing_plans/test_500_missing_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "X-Correlation-Id": correlation_id }, json={ diff --git a/tests/development/create_message_batches/test_performance.py b/tests/development/message_batches/create_message_batches/test_performance.py similarity index 90% rename from tests/development/create_message_batches/test_performance.py rename to tests/development/message_batches/create_message_batches/test_performance.py index c7b8f902d..5015d7f12 100644 --- a/tests/development/create_message_batches/test_performance.py +++ b/tests/development/message_batches/create_message_batches/test_performance.py @@ -3,6 +3,7 @@ import uuid from lib import Assertions, Generators from lib.constants.constants import NUM_MAX_ERRORS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT NUM_MESSAGES = 50000 CONTENT_TYPE = "application/json" @@ -27,7 +28,7 @@ def test_create_messages_large_invalid_payload(nhsd_apim_proxy_url, nhsd_apim_au "personalisation": {} }) - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "Accept": CONTENT_TYPE, "Content-Type": CONTENT_TYPE @@ -57,7 +58,7 @@ def test_create_messages_large_not_unique_payload(nhsd_apim_proxy_url, nhsd_apim "personalisation": {} }) - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "Accept": CONTENT_TYPE, "Content-Type": CONTENT_TYPE diff --git a/tests/development/create_message_batches/test_success.py b/tests/development/message_batches/create_message_batches/test_success.py similarity index 88% rename from tests/development/create_message_batches/test_success.py rename to tests/development/message_batches/create_message_batches/test_success.py index 10fab22e9..6db2a08e5 100644 --- a/tests/development/create_message_batches/test_success.py +++ b/tests/development/message_batches/create_message_batches/test_success.py @@ -2,8 +2,7 @@ import pytest from lib import Assertions, Generators import lib.constants.constants as constants - -REQUEST_PATH = "/v1/message-batches" +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT @pytest.mark.devtest @@ -15,7 +14,7 @@ def test_201_message_batch_valid_accept_headers(nhsd_apim_proxy_url, nhsd_apim_a """ data = Generators.generate_valid_create_message_batch_body("dev") resp = requests.post( - f"{nhsd_apim_proxy_url}{REQUEST_PATH}", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "Accept": accept_headers, @@ -34,7 +33,7 @@ def test_201_message_batch_valid_content_type_headers(nhsd_apim_proxy_url, nhsd_ .. include:: ../../partials/happy_path/test_201_message_batch_valid_content_type_headers.rst """ data = Generators.generate_valid_create_message_batch_body("dev") - resp = requests.post(f"{nhsd_apim_proxy_url}{REQUEST_PATH}", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": content_type @@ -52,7 +51,7 @@ def test_201_message_batch_valid_nhs_number(nhsd_apim_proxy_url, nhsd_apim_auth_ data = Generators.generate_valid_create_message_batch_body("dev") data["data"]["attributes"]["messages"][0]["recipient"]["nhsNumber"] = constants.VALID_NHS_NUMBER - resp = requests.post(f"{nhsd_apim_proxy_url}{REQUEST_PATH}", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE @@ -71,7 +70,7 @@ def test_201_message_batch_valid_dob(nhsd_apim_proxy_url, nhsd_apim_auth_headers data = Generators.generate_valid_create_message_batch_body("dev") data["data"]["attributes"]["messages"][0]["recipient"]["dateOfBirth"] = dob - resp = requests.post(f"{nhsd_apim_proxy_url}{REQUEST_PATH}", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE @@ -89,7 +88,7 @@ def test_request_without_dob(nhsd_apim_proxy_url, nhsd_apim_auth_headers): data = Generators.generate_valid_create_message_batch_body("dev") data["data"]["attributes"]["messages"][0]["recipient"].pop("dateOfBirth") - resp = requests.post(f"{nhsd_apim_proxy_url}{REQUEST_PATH}", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE diff --git a/tests/integration/authentication/__init__.py b/tests/development/message_batches/headers/__init__.py similarity index 100% rename from tests/integration/authentication/__init__.py rename to tests/development/message_batches/headers/__init__.py diff --git a/tests/development/headers/test_cors.py b/tests/development/message_batches/headers/test_cors.py similarity index 79% rename from tests/development/headers/test_cors.py rename to tests/development/message_batches/headers/test_cors.py index f82253553..a863dcbf2 100644 --- a/tests/development/headers/test_cors.py +++ b/tests/development/message_batches/headers/test_cors.py @@ -1,6 +1,7 @@ import requests import pytest from lib import Assertions +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"] @@ -17,7 +18,7 @@ def test_cors_options(nhsd_apim_proxy_url, method, nhsd_apim_auth_headers): .. include :: ../../partials/headers/test_cors_options.rst """ - resp = requests.options(f"{nhsd_apim_proxy_url}", headers={ + resp = requests.options(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "Accept": "*/*", "Origin": ORIGIN, @@ -35,7 +36,7 @@ def test_cors(nhsd_apim_proxy_url, method, nhsd_apim_auth_headers): .. include :: ../../partials/headers/test_cors.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "Accept": "*/*", "Origin": ORIGIN diff --git a/tests/development/headers/test_x_correlation_id.py b/tests/development/message_batches/headers/test_x_correlation_id.py similarity index 75% rename from tests/development/headers/test_x_correlation_id.py rename to tests/development/message_batches/headers/test_x_correlation_id.py index a984e829e..e99c0b19c 100644 --- a/tests/development/headers/test_x_correlation_id.py +++ b/tests/development/message_batches/headers/test_x_correlation_id.py @@ -1,21 +1,19 @@ import requests import pytest from lib import Error_Handler +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT CORRELATION_IDS = [None, "a17669c8-219a-11ee-ba86-322b0407c489"] -REQUEST_PATH = ["", "/", "/api/v1/send", "/v1/message-batches", "/v1/message-batches/"] METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] @pytest.mark.devtest -@pytest.mark.parametrize("request_path", REQUEST_PATH) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) @pytest.mark.nhsd_apim_authorization({"access": "application", "level": "level3"}) def test_request_with_x_correlation_id( nhsd_apim_proxy_url, - request_path, correlation_id, method, nhsd_apim_auth_headers @@ -25,7 +23,7 @@ def test_request_with_x_correlation_id( .. include:: ../../partials/headers/test_request_with_x_correlation_id.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{request_path}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "x-correlation-id": correlation_id }) diff --git a/tests/docs/development/generic/authentication.rst b/tests/docs/development/generic/authentication.rst index 4c2d80c45..fe55957e7 100644 --- a/tests/docs/development/generic/authentication.rst +++ b/tests/docs/development/generic/authentication.rst @@ -4,13 +4,13 @@ Authentication Tests 401 - Access Denied --------------------- -.. automodule:: development.authentication.test_401_errors +.. automodule:: development.message_batches.authentication.test_401_errors :noindex: :members: 403 - Forbidden --------------- -.. automodule:: development.authentication.test_403_errors +.. automodule:: development.message_batches.authentication.test_403_errors :noindex: :members: diff --git a/tests/docs/development/generic/content_types.rst b/tests/docs/development/generic/content_types.rst index 4b92cc743..ebfd7af7d 100644 --- a/tests/docs/development/generic/content_types.rst +++ b/tests/docs/development/generic/content_types.rst @@ -4,24 +4,24 @@ Content Types 406 - Not Acceptable -------------------- -.. automodule:: development.content_types.test_406_errors +.. automodule:: development.message_batches.content_types.test_406_errors :noindex: :members: -.. automodule:: development.content_types.test_missing_accept_header +.. automodule:: development.message_batches.content_types.test_missing_accept_header :noindex: :members: 415 - Unsupported Media ----------------------- -.. automodule:: development.content_types.test_415_errors +.. automodule:: development.message_batches.content_types.test_415_errors :noindex: :members: Content negotiation ------------------- -.. automodule:: development.content_types.test_content_type_negotiation +.. automodule:: development.message_batches.content_types.test_content_type_negotiation :noindex: :members: diff --git a/tests/docs/development/generic/headers.rst b/tests/docs/development/generic/headers.rst index e3805f143..f843867de 100644 --- a/tests/docs/development/generic/headers.rst +++ b/tests/docs/development/generic/headers.rst @@ -4,13 +4,13 @@ Header Tests CORS Responses -------------- -.. automodule:: development.headers.test_cors +.. automodule:: development.message_batches.headers.test_cors :noindex: :members: Correlation Id -------------- -.. automodule:: development.headers.test_x_correlation_id +.. automodule:: development.message_batches.headers.test_x_correlation_id :noindex: :members: diff --git a/tests/docs/development/post_v1_message-batches/happy_path.rst b/tests/docs/development/post_v1_message-batches/happy_path.rst index 4ad725e8d..7b94475b8 100644 --- a/tests/docs/development/post_v1_message-batches/happy_path.rst +++ b/tests/docs/development/post_v1_message-batches/happy_path.rst @@ -4,6 +4,6 @@ Happy Path Tests 201 - Success ------------- -.. automodule:: development.create_message_batches.test_success +.. automodule:: development.message_batches.create_message_batches.test_success :noindex: :members: diff --git a/tests/docs/development/post_v1_message-batches/invalid_routing_plans.rst b/tests/docs/development/post_v1_message-batches/invalid_routing_plans.rst index d594f00bf..d55856faa 100644 --- a/tests/docs/development/post_v1_message-batches/invalid_routing_plans.rst +++ b/tests/docs/development/post_v1_message-batches/invalid_routing_plans.rst @@ -1,6 +1,6 @@ Invalid Routing Plans ===================== -.. automodule:: development.create_message_batches.test_invalid_routing_plan +.. automodule:: development.message_batches.create_message_batches.test_invalid_routing_plan :noindex: :members: diff --git a/tests/docs/development/post_v1_message-batches/performance.rst b/tests/docs/development/post_v1_message-batches/performance.rst index 5790e7281..04b944367 100644 --- a/tests/docs/development/post_v1_message-batches/performance.rst +++ b/tests/docs/development/post_v1_message-batches/performance.rst @@ -1,6 +1,6 @@ Performance Tests ================= -.. automodule:: development.create_message_batches.test_performance +.. automodule:: development.message_batches.create_message_batches.test_performance :noindex: :members: diff --git a/tests/docs/development/post_v1_message-batches/validation.rst b/tests/docs/development/post_v1_message-batches/validation.rst index 093344caa..0655c2b59 100644 --- a/tests/docs/development/post_v1_message-batches/validation.rst +++ b/tests/docs/development/post_v1_message-batches/validation.rst @@ -1,6 +1,6 @@ Validation Tests ================ -.. automodule:: development.create_message_batches.test_field_validation +.. automodule:: development.message_batches.create_message_batches.test_field_validation :noindex: :members: diff --git a/tests/docs/integration/generic/authentication.rst b/tests/docs/integration/generic/authentication.rst index 48cdc34eb..5111ce429 100644 --- a/tests/docs/integration/generic/authentication.rst +++ b/tests/docs/integration/generic/authentication.rst @@ -4,6 +4,6 @@ Authentication Tests 401 - Access Denied --------------------- -.. automodule:: integration.authentication.test_401_errors +.. automodule:: integration.message_batches.authentication.test_401_errors :noindex: :members: \ No newline at end of file diff --git a/tests/docs/integration/generic/content_types.rst b/tests/docs/integration/generic/content_types.rst index 6de4296e4..4db150df1 100644 --- a/tests/docs/integration/generic/content_types.rst +++ b/tests/docs/integration/generic/content_types.rst @@ -4,20 +4,20 @@ Content Types 406 - Not Acceptable -------------------- -.. automodule:: integration.content_types.test_406_errors +.. automodule:: integration.message_batches.content_types.test_406_errors :noindex: :members: 415 - Unsupported Media ----------------------- -.. automodule:: integration.content_types.test_415_errors +.. automodule:: integration.message_batches.content_types.test_415_errors :noindex: :members: Content negotiation ------------------- -.. automodule:: integration.content_types.test_content_type_negotiation +.. automodule:: integration.message_batches.content_types.test_content_type_negotiation :noindex: :members: diff --git a/tests/docs/integration/generic/headers.rst b/tests/docs/integration/generic/headers.rst index daf0d683e..10018494e 100644 --- a/tests/docs/integration/generic/headers.rst +++ b/tests/docs/integration/generic/headers.rst @@ -4,13 +4,13 @@ Header Tests CORS Responses -------------- -.. automodule:: integration.headers.test_cors +.. automodule:: integration.message_batches.headers.test_cors :noindex: :members: Correlation Id -------------- -.. automodule:: integration.headers.test_x_correlation_id +.. automodule:: integration.message_batches.headers.test_x_correlation_id :noindex: :members: diff --git a/tests/docs/integration/post_v1_message-batches/happy_path.rst b/tests/docs/integration/post_v1_message-batches/happy_path.rst index 3319df35c..e5511e8eb 100644 --- a/tests/docs/integration/post_v1_message-batches/happy_path.rst +++ b/tests/docs/integration/post_v1_message-batches/happy_path.rst @@ -4,6 +4,6 @@ Happy Path Tests 201 - Success ------------- -.. automodule:: integration.create_message_batches.test_success +.. automodule:: integration.message_batches.create_message_batches.test_success :noindex: :members: diff --git a/tests/docs/integration/post_v1_message-batches/invalid_routing_plans.rst b/tests/docs/integration/post_v1_message-batches/invalid_routing_plans.rst index c7bb49f36..42a74c37d 100644 --- a/tests/docs/integration/post_v1_message-batches/invalid_routing_plans.rst +++ b/tests/docs/integration/post_v1_message-batches/invalid_routing_plans.rst @@ -1,6 +1,6 @@ Invalid Routing Plans ===================== -.. automodule:: integration.create_message_batches.test_invalid_routing_plan +.. automodule:: integration.message_batches.create_message_batches.test_invalid_routing_plan :noindex: :members: diff --git a/tests/docs/integration/post_v1_message-batches/performance.rst b/tests/docs/integration/post_v1_message-batches/performance.rst index d19122f12..1a4ac73fb 100644 --- a/tests/docs/integration/post_v1_message-batches/performance.rst +++ b/tests/docs/integration/post_v1_message-batches/performance.rst @@ -1,6 +1,6 @@ Performance Tests ================= -.. automodule:: integration.create_message_batches.test_performance +.. automodule:: integration.message_batches.create_message_batches.test_performance :noindex: :members: diff --git a/tests/docs/integration/post_v1_message-batches/validation.rst b/tests/docs/integration/post_v1_message-batches/validation.rst index f6b01946d..b4e2b924d 100644 --- a/tests/docs/integration/post_v1_message-batches/validation.rst +++ b/tests/docs/integration/post_v1_message-batches/validation.rst @@ -1,6 +1,6 @@ Validation Tests ================ -.. automodule:: integration.create_message_batches.test_field_validation +.. automodule:: integration.message_batches.create_message_batches.test_field_validation :noindex: :members: diff --git a/tests/docs/production/generic/authentication.rst b/tests/docs/production/generic/authentication.rst index c7e5d09c8..29ec83426 100644 --- a/tests/docs/production/generic/authentication.rst +++ b/tests/docs/production/generic/authentication.rst @@ -4,6 +4,6 @@ Authentication Tests 401 - Access Denied --------------------- -.. automodule:: production.authentication.test_401_errors +.. automodule:: production.message_batches.authentication.test_401_errors :noindex: :members: \ No newline at end of file diff --git a/tests/docs/production/generic/content_types.rst b/tests/docs/production/generic/content_types.rst index 6b4fc457e..f20d7d93e 100644 --- a/tests/docs/production/generic/content_types.rst +++ b/tests/docs/production/generic/content_types.rst @@ -4,20 +4,20 @@ Content Types 406 - Not Acceptable -------------------- -.. automodule:: production.content_types.test_406_errors +.. automodule:: production.message_batches.content_types.test_406_errors :noindex: :members: 415 - Unsupported Media ----------------------- -.. automodule:: production.content_types.test_415_errors +.. automodule:: production.message_batches.content_types.test_415_errors :noindex: :members: Content negotiation ------------------- -.. automodule:: production.content_types.test_content_type_negotiation +.. automodule:: production.message_batches.content_types.test_content_type_negotiation :noindex: :members: diff --git a/tests/docs/production/generic/headers.rst b/tests/docs/production/generic/headers.rst index f88d6798e..f5ef79894 100644 --- a/tests/docs/production/generic/headers.rst +++ b/tests/docs/production/generic/headers.rst @@ -4,13 +4,13 @@ Header Tests CORS Responses -------------- -.. automodule:: production.headers.test_cors +.. automodule:: production.message_batches.headers.test_cors :noindex: :members: Correlation Id -------------- -.. automodule:: production.headers.test_x_correlation_id +.. automodule:: production.message_batches.headers.test_x_correlation_id :noindex: :members: diff --git a/tests/docs/production/post_v1_message-batches/invalid_routing_plans.rst b/tests/docs/production/post_v1_message-batches/invalid_routing_plans.rst index b718b8063..98ed8624c 100644 --- a/tests/docs/production/post_v1_message-batches/invalid_routing_plans.rst +++ b/tests/docs/production/post_v1_message-batches/invalid_routing_plans.rst @@ -1,6 +1,6 @@ Invalid Routing Plans ===================== -.. automodule:: production.create_message_batches.test_invalid_routing_config +.. automodule:: production.message_batches.create_message_batches.test_invalid_routing_config :noindex: :members: diff --git a/tests/docs/production/post_v1_message-batches/performance.rst b/tests/docs/production/post_v1_message-batches/performance.rst index 591425070..80610afcb 100644 --- a/tests/docs/production/post_v1_message-batches/performance.rst +++ b/tests/docs/production/post_v1_message-batches/performance.rst @@ -1,6 +1,6 @@ Performance Tests ================= -.. automodule:: production.create_message_batches.test_performance +.. automodule:: production.message_batches.create_message_batches.test_performance :noindex: :members: diff --git a/tests/docs/production/post_v1_message-batches/validation.rst b/tests/docs/production/post_v1_message-batches/validation.rst index 1d528d33a..70437c515 100644 --- a/tests/docs/production/post_v1_message-batches/validation.rst +++ b/tests/docs/production/post_v1_message-batches/validation.rst @@ -1,6 +1,6 @@ Validation Tests ================ -.. automodule:: production.create_message_batches.test_field_validation +.. automodule:: production.message_batches.create_message_batches.test_field_validation :noindex: :members: diff --git a/tests/docs/sandbox/generic/authentication.rst b/tests/docs/sandbox/generic/authentication.rst index dbeddb3fe..745a4d6f4 100644 --- a/tests/docs/sandbox/generic/authentication.rst +++ b/tests/docs/sandbox/generic/authentication.rst @@ -4,12 +4,12 @@ Authentication Tests 401 - Access Denied ------------------- -.. automodule:: sandbox.authentication.test_401_errors +.. automodule:: sandbox.message_batches.authentication.test_401_errors :noindex: :members: 403 - Forbidden --------------- -.. automodule:: sandbox.authentication.test_403_errors +.. automodule:: sandbox.message_batches.authentication.test_403_errors :members: diff --git a/tests/docs/sandbox/generic/content_types.rst b/tests/docs/sandbox/generic/content_types.rst index ed3d058b5..26ad5400b 100644 --- a/tests/docs/sandbox/generic/content_types.rst +++ b/tests/docs/sandbox/generic/content_types.rst @@ -4,20 +4,20 @@ Content Types 406 - Not Acceptable -------------------- -.. automodule:: sandbox.content_types.test_406_errors +.. automodule:: sandbox.message_batches.content_types.test_406_errors :noindex: :members: 415 - Unsupported Media ----------------------- -.. automodule:: sandbox.content_types.test_415_errors +.. automodule:: sandbox.message_batches.content_types.test_415_errors :noindex: :members: Content negotiation ------------------- -.. automodule:: sandbox.content_types.test_content_negotiation +.. automodule:: sandbox.message_batches.content_types.test_content_negotiation :noindex: :members: diff --git a/tests/docs/sandbox/generic/headers.rst b/tests/docs/sandbox/generic/headers.rst index 64d093b67..00000d1de 100644 --- a/tests/docs/sandbox/generic/headers.rst +++ b/tests/docs/sandbox/generic/headers.rst @@ -4,13 +4,13 @@ Header Tests CORS Responses -------------- -.. automodule:: sandbox.headers.test_cors +.. automodule:: sandbox.message_batches.headers.test_cors :noindex: :members: Correlation Id -------------- -.. automodule:: sandbox.headers.test_x_correlation_id +.. automodule:: sandbox.message_batches.headers.test_x_correlation_id :noindex: :members: diff --git a/tests/docs/sandbox/post_v1_message-batches/happy_path.rst b/tests/docs/sandbox/post_v1_message-batches/happy_path.rst index a33d2b129..8afe0de50 100644 --- a/tests/docs/sandbox/post_v1_message-batches/happy_path.rst +++ b/tests/docs/sandbox/post_v1_message-batches/happy_path.rst @@ -6,6 +6,6 @@ These tests target the API endpoint v1/message-batches testing successful respon 201 - Success ------------- -.. automodule:: sandbox.create_message_batches.test_success +.. automodule:: sandbox.message_batches.create_message_batches.test_success :noindex: :members: diff --git a/tests/docs/sandbox/post_v1_message-batches/invalid_routing_plans.rst b/tests/docs/sandbox/post_v1_message-batches/invalid_routing_plans.rst index 964273097..e9a5237e7 100644 --- a/tests/docs/sandbox/post_v1_message-batches/invalid_routing_plans.rst +++ b/tests/docs/sandbox/post_v1_message-batches/invalid_routing_plans.rst @@ -1,6 +1,6 @@ Invalid Routing Plans ===================== -.. automodule:: sandbox.create_message_batches.test_invalid_routing_plan +.. automodule:: sandbox.message_batches.create_message_batches.test_invalid_routing_plan :noindex: :members: diff --git a/tests/docs/sandbox/post_v1_message-batches/performance.rst b/tests/docs/sandbox/post_v1_message-batches/performance.rst index 781fd4fca..7a07c95d3 100644 --- a/tests/docs/sandbox/post_v1_message-batches/performance.rst +++ b/tests/docs/sandbox/post_v1_message-batches/performance.rst @@ -1,6 +1,6 @@ Performance Tests ================= -.. automodule:: sandbox.create_message_batches.test_performance +.. automodule:: sandbox.message_batches.create_message_batches.test_performance :noindex: :members: diff --git a/tests/docs/sandbox/post_v1_message-batches/retry_too_early.rst b/tests/docs/sandbox/post_v1_message-batches/retry_too_early.rst index 877c58af7..74c96e031 100644 --- a/tests/docs/sandbox/post_v1_message-batches/retry_too_early.rst +++ b/tests/docs/sandbox/post_v1_message-batches/retry_too_early.rst @@ -1,6 +1,6 @@ Retry Too Early =============== -.. automodule:: sandbox.create_message_batches.test_retry_too_early +.. automodule:: sandbox.message_batches.create_message_batches.test_retry_too_early :noindex: :members: diff --git a/tests/docs/sandbox/post_v1_message-batches/service_ban.rst b/tests/docs/sandbox/post_v1_message-batches/service_ban.rst index ef26f6f2d..a17820cf6 100644 --- a/tests/docs/sandbox/post_v1_message-batches/service_ban.rst +++ b/tests/docs/sandbox/post_v1_message-batches/service_ban.rst @@ -1,6 +1,6 @@ Service Ban =========== -.. automodule:: sandbox.create_message_batches.test_service_ban +.. automodule:: sandbox.message_batches.create_message_batches.test_service_ban :noindex: :members: diff --git a/tests/docs/sandbox/post_v1_message-batches/validation.rst b/tests/docs/sandbox/post_v1_message-batches/validation.rst index 3af741f04..cc4391a58 100644 --- a/tests/docs/sandbox/post_v1_message-batches/validation.rst +++ b/tests/docs/sandbox/post_v1_message-batches/validation.rst @@ -1,6 +1,6 @@ Validation Tests ================ -.. automodule:: sandbox.create_message_batches.test_field_validation +.. automodule:: sandbox.message_batches.create_message_batches.test_field_validation :noindex: :members: diff --git a/tests/docs/sandbox/post_v1_messages/invalid_routing_plans.rst b/tests/docs/sandbox/post_v1_messages/invalid_routing_plans.rst index 0992f15fa..43f3ded29 100644 --- a/tests/docs/sandbox/post_v1_messages/invalid_routing_plans.rst +++ b/tests/docs/sandbox/post_v1_messages/invalid_routing_plans.rst @@ -1,6 +1,6 @@ Invalid Routing Plans ===================== -.. automodule:: sandbox.create_messages.test_invalid_routing_plan +.. automodule:: sandbox.messages.create_messages.test_invalid_routing_plan :noindex: :members: diff --git a/tests/docs/sandbox/post_v1_messages/validation.rst b/tests/docs/sandbox/post_v1_messages/validation.rst index 28ebb7b81..7897933db 100644 --- a/tests/docs/sandbox/post_v1_messages/validation.rst +++ b/tests/docs/sandbox/post_v1_messages/validation.rst @@ -1,6 +1,6 @@ Validation Tests ================ -.. automodule:: sandbox.create_messages.test_field_validation +.. automodule:: sandbox.messages.create_messages.test_field_validation :noindex: :members: diff --git a/tests/integration/content_types/__init__.py b/tests/integration/message_batches/__init__.py similarity index 100% rename from tests/integration/content_types/__init__.py rename to tests/integration/message_batches/__init__.py diff --git a/tests/integration/create_message_batches/__init__.py b/tests/integration/message_batches/authentication/__init__.py similarity index 100% rename from tests/integration/create_message_batches/__init__.py rename to tests/integration/message_batches/authentication/__init__.py diff --git a/tests/integration/authentication/test_401_errors.py b/tests/integration/message_batches/authentication/test_401_errors.py similarity index 80% rename from tests/integration/authentication/test_401_errors.py rename to tests/integration/message_batches/authentication/test_401_errors.py index 2fb062221..f87a76453 100644 --- a/tests/integration/authentication/test_401_errors.py +++ b/tests/integration/message_batches/authentication/test_401_errors.py @@ -2,6 +2,7 @@ import pytest from lib import Assertions, Generators from lib.constants.constants import TOKENS, CORRELATION_IDS, METHODS, INT_URL +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT @pytest.mark.inttest @@ -12,7 +13,7 @@ def test_401_invalid(invalid_token, correlation_id, method): """ .. include:: ../../partials/authentication/test_401_invalid.rst """ - resp = getattr(requests, method)(INT_URL, headers={ + resp = getattr(requests, method)(f"{INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": invalid_token, "X-Correlation-Id": correlation_id }) diff --git a/tests/integration/headers/__init__.py b/tests/integration/message_batches/content_types/__init__.py similarity index 100% rename from tests/integration/headers/__init__.py rename to tests/integration/message_batches/content_types/__init__.py diff --git a/tests/integration/content_types/test_406_errors.py b/tests/integration/message_batches/content_types/test_406_errors.py similarity index 86% rename from tests/integration/content_types/test_406_errors.py rename to tests/integration/message_batches/content_types/test_406_errors.py index 8967866b9..c75e3e3e1 100644 --- a/tests/integration/content_types/test_406_errors.py +++ b/tests/integration/message_batches/content_types/test_406_errors.py @@ -2,29 +2,27 @@ import pytest from lib import Assertions, Generators, Authentication from lib.constants.constants import CORRELATION_IDS, METHODS, INT_URL, DEFAULT_CONTENT_TYPE +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT HEADER_NAME = ["accept", "ACCEPT", "Accept", "AcCePt"] HEADER_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] -REQUEST_PATH = ["/v1/ignore", "/api/ignore"] @pytest.mark.inttest @pytest.mark.parametrize("accept_header_name", HEADER_NAME) @pytest.mark.parametrize("accept_header_value", HEADER_VALUE) -@pytest.mark.parametrize("request_path", REQUEST_PATH) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) def test_406( accept_header_name, accept_header_value, - request_path, correlation_id, method, ): """ .. include:: ../../partials/content_types/test_406.rst """ - resp = getattr(requests, method)(f"{INT_URL}/{request_path}", headers={ + resp = getattr(requests, method)(f"{INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ accept_header_name: accept_header_value, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('int')}" diff --git a/tests/integration/content_types/test_415_errors.py b/tests/integration/message_batches/content_types/test_415_errors.py similarity index 86% rename from tests/integration/content_types/test_415_errors.py rename to tests/integration/message_batches/content_types/test_415_errors.py index 8e8fb6ddd..e89ecf65b 100644 --- a/tests/integration/content_types/test_415_errors.py +++ b/tests/integration/message_batches/content_types/test_415_errors.py @@ -2,30 +2,28 @@ import pytest from lib import Assertions, Generators, Authentication from lib.constants.constants import INT_URL, CORRELATION_IDS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT CONTENT_TYPE_NAME = ["content-type", "CONTENT_TYPE", "Content_Type", "conTENT_tYpe"] CONTENT_TYPE_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] -REQUEST_PATH = ["/v1/ignore", "/api/ignore"] METHODS = ["post", "put", "patch"] @pytest.mark.inttest @pytest.mark.parametrize("content_type_name", CONTENT_TYPE_NAME) @pytest.mark.parametrize("content_type_value", CONTENT_TYPE_VALUE) -@pytest.mark.parametrize("request_path", REQUEST_PATH) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) def test_415_invalid( content_type_name, content_type_value, - request_path, correlation_id, method ): """ .. include:: ../../partials/content_types/test_415_invalid.rst """ - resp = getattr(requests, method)(f"{INT_URL}{request_path}", headers={ + resp = getattr(requests, method)(f"{INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": f"{Authentication.generate_authentication('int')}", "Accept": "application/json", content_type_name: content_type_value, diff --git a/tests/integration/content_types/test_content_type_negotiation.py b/tests/integration/message_batches/content_types/test_content_type_negotiation.py similarity index 87% rename from tests/integration/content_types/test_content_type_negotiation.py rename to tests/integration/message_batches/content_types/test_content_type_negotiation.py index 88ac07f1a..340afd32a 100644 --- a/tests/integration/content_types/test_content_type_negotiation.py +++ b/tests/integration/message_batches/content_types/test_content_type_negotiation.py @@ -2,6 +2,7 @@ import pytest from lib import Authentication, Error_Handler from lib.constants.constants import INT_URL, METHODS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT DEFAULT_CONTENT_TYPE = "application/vnd.api+json" ACCEPT_HEADERS = [ @@ -33,7 +34,7 @@ def test_application_response_type(accept_headers, method): """ .. include:: ../../partials/content_types/test_application_response_type.rst """ - resp = getattr(requests, method)(f"{INT_URL}", headers={ + resp = getattr(requests, method)(f"{INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": f"{Authentication.generate_authentication('int')}", **accept_headers.get("headers") }) diff --git a/tests/production/authentication/__init__.py b/tests/integration/message_batches/create_message_batches/__init__.py similarity index 100% rename from tests/production/authentication/__init__.py rename to tests/integration/message_batches/create_message_batches/__init__.py diff --git a/tests/integration/create_message_batches/test_field_validation.py b/tests/integration/message_batches/create_message_batches/test_field_validation.py similarity index 91% rename from tests/integration/create_message_batches/test_field_validation.py rename to tests/integration/message_batches/create_message_batches/test_field_validation.py index d4fa1d4e1..9cba25818 100644 --- a/tests/integration/create_message_batches/test_field_validation.py +++ b/tests/integration/message_batches/create_message_batches/test_field_validation.py @@ -3,8 +3,9 @@ import uuid from lib import Assertions, Permutations, Generators, Authentication import lib.constants.constants as constants -from lib.constants.message_batches_paths import * - +from lib.constants.message_batches_paths import MISSING_PROPERTIES_PATHS, NULL_PROPERTIES_PATHS, \ + INVALID_PROPERTIES_PATHS, DUPLICATE_PROPERTIES_PATHS, TOO_FEW_PROPERTIES_PATHS, MESSAGE_BATCH_REFERENCE_PATH, \ + FIRST_MESSAGE_RECIPIENT_NHSNUMBER_PATH, FIRST_MESSAGE_REFERENCE_PATH, MESSAGE_BATCHES_ENDPOINT, ROUTING_PLAN_ID_PATH headers = { "Accept": "application/json", "Content-Type": "application/json" @@ -18,7 +19,7 @@ def test_invalid_body(correlation_id): .. include:: ../../partials/validation/test_invalid_body.rst """ resp = requests.post( - f"{constants.INT_URL}/v1/message-batches", + f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, @@ -46,7 +47,7 @@ def test_property_missing(property, pointer, correlation_id): .. include:: ../../partials/validation/test_property_missing.rst """ resp = requests.post( - f"{constants.INT_URL}/v1/message-batches", + f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, @@ -77,7 +78,7 @@ def test_data_null(property, pointer, correlation_id): .. include:: ../../partials/validation/test_data_null.rst """ resp = requests.post( - f"{constants.INT_URL}/v1/message-batches", + f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, @@ -108,7 +109,7 @@ def test_data_invalid(property, pointer, correlation_id): .. include:: ../../partials/validation/test_data_invalid.rst """ resp = requests.post( - f"{constants.INT_URL}/v1/message-batches", + f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, @@ -145,7 +146,7 @@ def test_data_duplicate(property, pointer, correlation_id): # Post the same message a 2nd time to trigger the duplicate error resp = requests.post( - f"{constants.INT_URL}/v1/message-batches", + f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, @@ -173,7 +174,7 @@ def test_data_too_few_items(property, pointer, correlation_id): .. include:: ../../partials/validation/test_data_too_few_items.rst """ resp = requests.post( - f"{constants.INT_URL}/v1/message-batches", + f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, @@ -201,7 +202,7 @@ def test_invalid_nhs_number(nhs_number, correlation_id): """ .. include:: ../../partials/validation/test_invalid_nhs_number.rst """ - resp = requests.post(f"{constants.INT_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('int')}" @@ -240,7 +241,7 @@ def test_invalid_dob(dob, correlation_id): """ .. include:: ../../partials/validation/test_invalid_dob.rst """ - resp = requests.post(f"{constants.INT_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('int')}" @@ -278,7 +279,7 @@ def test_invalid_routing_plan(correlation_id): """ .. include:: ../../partials/validation/test_invalid_routing_plan.rst """ - resp = requests.post(f"{constants.INT_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('int')}" @@ -316,7 +317,7 @@ def test_invalid_message_batch_reference(correlation_id): """ .. include:: ../../partials/validation/test_invalid_message_batch_reference.rst """ - resp = requests.post(f"{constants.INT_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('int')}" @@ -354,7 +355,7 @@ def test_invalid_message_reference(correlation_id): """ .. include:: ../../partials/validation/test_invalid_message_reference.rst """ - resp = requests.post(f"{constants.INT_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('int')}" @@ -393,7 +394,7 @@ def test_blank_value_under_messages(invalid_value, correlation_id): """ .. include:: ../../partials/validation/test_blank_value_under_messages.rst """ - resp = requests.post(f"{constants.INT_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('int')}" @@ -424,7 +425,7 @@ def test_null_value_under_messages(correlation_id): """ .. include:: ../../partials/validation/test_null_value_under_messages.rst """ - resp = requests.post(f"{constants.INT_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('int')}" diff --git a/tests/integration/create_message_batches/test_invalid_routing_plan.py b/tests/integration/message_batches/create_message_batches/test_invalid_routing_plan.py similarity index 92% rename from tests/integration/create_message_batches/test_invalid_routing_plan.py rename to tests/integration/message_batches/create_message_batches/test_invalid_routing_plan.py index f735d5358..0accf4d74 100644 --- a/tests/integration/create_message_batches/test_invalid_routing_plan.py +++ b/tests/integration/message_batches/create_message_batches/test_invalid_routing_plan.py @@ -2,6 +2,7 @@ import pytest import uuid from lib import Assertions, Generators +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT CORRELATION_IDS = [None, "228aac39-542d-4803-b28e-5de9e100b9f8"] METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] @@ -15,7 +16,7 @@ def test_no_such_routing_plan(nhsd_apim_proxy_url, correlation_id, nhsd_apim_aut """ .. include:: ../../partials/invalid_routing_plans/test_no_such_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "X-Correlation-Id": correlation_id }, json={ @@ -53,7 +54,7 @@ def test_routing_plan_not_belonging_to_client_id(nhsd_apim_proxy_url, correlatio """ .. include:: ../../partials/invalid_routing_plans/test_routing_plan_not_belonging_to_client_id.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **nhsd_apim_auth_headers, "X-Correlation-Id": correlation_id }, json={ diff --git a/tests/integration/create_message_batches/test_performance.py b/tests/integration/message_batches/create_message_batches/test_performance.py similarity index 90% rename from tests/integration/create_message_batches/test_performance.py rename to tests/integration/message_batches/create_message_batches/test_performance.py index c26e87e94..03eff9169 100644 --- a/tests/integration/create_message_batches/test_performance.py +++ b/tests/integration/message_batches/create_message_batches/test_performance.py @@ -3,6 +3,7 @@ import uuid from lib import Assertions, Generators, Authentication from lib.constants.constants import NUM_MAX_ERRORS, INT_URL +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT NUM_MESSAGES = 50000 CONTENT_TYPE = "application/json" @@ -26,7 +27,7 @@ def test_create_messages_large_invalid_payload(): "personalisation": {} }) - resp = requests.post(f"{INT_URL}/v1/message-batches", headers={ + resp = requests.post(f"{INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": CONTENT_TYPE, "Content-Type": CONTENT_TYPE, "Authorization": f"{Authentication.generate_authentication('int')}" @@ -55,7 +56,7 @@ def test_create_messages_large_not_unique_payload(): "personalisation": {} }) - resp = requests.post(f"{INT_URL}/v1/message-batches", headers={ + resp = requests.post(f"{INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": CONTENT_TYPE, "Content-Type": CONTENT_TYPE, "Authorization": f"{Authentication.generate_authentication('int')}" diff --git a/tests/integration/create_message_batches/test_success.py b/tests/integration/message_batches/create_message_batches/test_success.py similarity index 86% rename from tests/integration/create_message_batches/test_success.py rename to tests/integration/message_batches/create_message_batches/test_success.py index 9d283bba6..ebc6eccc9 100644 --- a/tests/integration/create_message_batches/test_success.py +++ b/tests/integration/message_batches/create_message_batches/test_success.py @@ -2,8 +2,7 @@ import pytest from lib import Assertions, Generators, Authentication import lib.constants.constants as constants - -REQUEST_PATH = "/v1/message-batches" +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT @pytest.mark.inttest @@ -15,7 +14,7 @@ def test_201_message_batch_valid_accept_headers(accept_headers): data = Generators.generate_valid_create_message_batch_body("int") resp = requests.post( - f"{constants.INT_URL}{REQUEST_PATH}", + f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": Authentication.generate_authentication("int"), "Accept": accept_headers, @@ -34,7 +33,7 @@ def test_201_message_batch_valid_content_type_headers(content_type): """ data = Generators.generate_valid_create_message_batch_body("int") - resp = requests.post(f"{constants.INT_URL}{REQUEST_PATH}", headers={ + resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": Authentication.generate_authentication("int"), "Accept": "application/json", "Content-Type": content_type @@ -50,7 +49,7 @@ def test_201_message_batch_valid_nhs_number(): """ data = Generators.generate_valid_create_message_batch_body("int") - resp = requests.post(f"{constants.INT_URL}{REQUEST_PATH}", headers={ + resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": Authentication.generate_authentication("int"), "Accept": "application/json", "Content-Type": "application/json" @@ -68,7 +67,7 @@ def test_201_message_batch_valid_dob(dob): data = Generators.generate_valid_create_message_batch_body("int") data["data"]["attributes"]["messages"][0]["recipient"]["dateOfBirth"] = dob - resp = requests.post(f"{constants.INT_URL}{REQUEST_PATH}", headers={ + resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": Authentication.generate_authentication("int"), "Accept": "application/json", "Content-Type": "application/json" @@ -85,7 +84,7 @@ def test_request_without_dob(): data = Generators.generate_valid_create_message_batch_body("int") data["data"]["attributes"]["messages"][0]["recipient"].pop("dateOfBirth") - resp = requests.post(f"{constants.INT_URL}{REQUEST_PATH}", headers={ + resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": Authentication.generate_authentication("int"), "Accept": "application/json", "Content-Type": "application/json" diff --git a/tests/production/content_types/__init__.py b/tests/integration/message_batches/headers/__init__.py similarity index 100% rename from tests/production/content_types/__init__.py rename to tests/integration/message_batches/headers/__init__.py diff --git a/tests/integration/headers/test_cors.py b/tests/integration/message_batches/headers/test_cors.py similarity index 78% rename from tests/integration/headers/test_cors.py rename to tests/integration/message_batches/headers/test_cors.py index afbb1e4f5..41d6a70e9 100644 --- a/tests/integration/headers/test_cors.py +++ b/tests/integration/message_batches/headers/test_cors.py @@ -2,6 +2,7 @@ import pytest from lib import Assertions, Authentication from lib.constants.constants import INT_URL +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"] @@ -14,7 +15,7 @@ def test_cors_options(method): """ .. include :: ../../partials/headers/test_cors_options.rst """ - resp = requests.options(f"{INT_URL}", headers={ + resp = requests.options(f"{INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": f"{Authentication.generate_authentication('int')}", "Accept": "*/*", "Origin": "https://my.website", @@ -29,7 +30,7 @@ def test_cors(method): """ .. include :: ../../partials/headers/test_cors.rst """ - resp = getattr(requests, method)(f"{INT_URL}", headers={ + resp = getattr(requests, method)(f"{INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": f"{Authentication.generate_authentication('int')}", "Accept": "*/*", "Origin": "https://my.website" diff --git a/tests/integration/headers/test_x_correlation_id.py b/tests/integration/message_batches/headers/test_x_correlation_id.py similarity index 65% rename from tests/integration/headers/test_x_correlation_id.py rename to tests/integration/message_batches/headers/test_x_correlation_id.py index b469cd627..fb9f1fef2 100644 --- a/tests/integration/headers/test_x_correlation_id.py +++ b/tests/integration/message_batches/headers/test_x_correlation_id.py @@ -2,24 +2,19 @@ import pytest from lib import Authentication, Error_Handler from lib.constants.constants import INT_URL, METHODS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT CORRELATION_IDS = [None, "a17669c8-219a-11ee-ba86-322b0407c489"] -REQUEST_PATH = ["", "/", "/api/v1/send", "/v1/message-batches", "/v1/message-batches/"] @pytest.mark.inttest -@pytest.mark.parametrize("request_path", REQUEST_PATH) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) -def test_request_with_x_correlation_id( - request_path, - correlation_id, - method, -): +def test_request_with_x_correlation_id(correlation_id, method): """ .. include:: ../../partials/headers/test_request_with_x_correlation_id.rst """ - resp = getattr(requests, method)(f"{INT_URL}{request_path}", headers={ + resp = getattr(requests, method)(f"{INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": f"{Authentication.generate_authentication('int')}", "x-correlation-id": correlation_id }) diff --git a/tests/lib/constants/message_batches_paths.py b/tests/lib/constants/message_batches_paths.py index 950fbf3c3..f5b6f1ad4 100644 --- a/tests/lib/constants/message_batches_paths.py +++ b/tests/lib/constants/message_batches_paths.py @@ -1,6 +1,6 @@ from lib.constants.shared_paths import ROUTING_PLAN_ID_PATH - +MESSAGE_BATCHES_ENDPOINT = "/v1/message-batches" MESSAGE_BATCH_REFERENCE_PATH = "/data/attributes/messageBatchReference" MESSAGES_PATH = "/data/attributes/messages" FIRST_MESSAGE_REFERENCE_PATH = "/data/attributes/messages/0/messageReference" diff --git a/tests/lib/constants/messages_paths.py b/tests/lib/constants/messages_paths.py index 3bc52d64b..29e5dd9c8 100644 --- a/tests/lib/constants/messages_paths.py +++ b/tests/lib/constants/messages_paths.py @@ -1,7 +1,7 @@ from lib.constants.shared_paths import ROUTING_PLAN_ID_PATH - +MESSAGES_ENDPOINT = "/v1/messages" MESSAGE_REFERENCE_PATH = "/data/attributes/messageReference" MESSAGE_RECIPIENT_PATH = "/data/attributes/recipient" MESSAGE_RECIPIENT_NHSNUMBER_PATH = "/data/attributes/recipient/nhsNumber" diff --git a/tests/production/create_message_batches/__init__.py b/tests/production/message_batches/__init__.py similarity index 100% rename from tests/production/create_message_batches/__init__.py rename to tests/production/message_batches/__init__.py diff --git a/tests/production/headers/__init__.py b/tests/production/message_batches/authentication/__init__.py similarity index 100% rename from tests/production/headers/__init__.py rename to tests/production/message_batches/authentication/__init__.py diff --git a/tests/production/authentication/test_401_errors.py b/tests/production/message_batches/authentication/test_401_errors.py similarity index 79% rename from tests/production/authentication/test_401_errors.py rename to tests/production/message_batches/authentication/test_401_errors.py index 1b4c7436a..ff17bb581 100644 --- a/tests/production/authentication/test_401_errors.py +++ b/tests/production/message_batches/authentication/test_401_errors.py @@ -2,6 +2,7 @@ import pytest from lib import Assertions, Generators from lib.constants.constants import * +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT @pytest.mark.prodtest @@ -12,7 +13,7 @@ def test_401_invalid(invalid_token, correlation_id, method): """ .. include:: ../../partials/authentication/test_401_invalid.rst """ - resp = getattr(requests, method)(PROD_URL, headers={ + resp = getattr(requests, method)(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": invalid_token, "X-Correlation-Id": correlation_id }) diff --git a/tests/sandbox/authentication/__init__.py b/tests/production/message_batches/content_types/__init__.py similarity index 100% rename from tests/sandbox/authentication/__init__.py rename to tests/production/message_batches/content_types/__init__.py diff --git a/tests/production/content_types/test_406_errors.py b/tests/production/message_batches/content_types/test_406_errors.py similarity index 79% rename from tests/production/content_types/test_406_errors.py rename to tests/production/message_batches/content_types/test_406_errors.py index f85ed167b..6f9dd8f87 100644 --- a/tests/production/content_types/test_406_errors.py +++ b/tests/production/message_batches/content_types/test_406_errors.py @@ -1,30 +1,28 @@ import requests import pytest from lib import Assertions, Generators, Authentication -from lib.constants.constants import * +from lib.constants.constants import CORRELATION_IDS, METHODS, PROD_URL +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT HEADER_NAME = ["accept", "ACCEPT", "Accept", "AcCePt"] HEADER_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] -REQUEST_PATH = ["/v1/ignore", "/api/ignore"] @pytest.mark.prodtest @pytest.mark.parametrize("accept_header_name", HEADER_NAME) @pytest.mark.parametrize("accept_header_value", HEADER_VALUE) -@pytest.mark.parametrize("request_path", REQUEST_PATH) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) def test_406( accept_header_name, accept_header_value, - request_path, correlation_id, method, ): """ .. include:: ../../partials/content_types/test_406.rst """ - resp = getattr(requests, method)(f"{PROD_URL}/{request_path}", headers={ + resp = getattr(requests, method)(f"{PROD_URL}/{MESSAGE_BATCHES_ENDPOINT}", headers={ accept_header_name: accept_header_value, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('prod')}", diff --git a/tests/production/content_types/test_415_errors.py b/tests/production/message_batches/content_types/test_415_errors.py similarity index 80% rename from tests/production/content_types/test_415_errors.py rename to tests/production/message_batches/content_types/test_415_errors.py index 4b8fd69ae..e5dc973a7 100644 --- a/tests/production/content_types/test_415_errors.py +++ b/tests/production/message_batches/content_types/test_415_errors.py @@ -1,31 +1,29 @@ import requests import pytest from lib import Assertions, Generators, Authentication -from lib.constants.constants import * +from lib.constants.constants import CORRELATION_IDS, PROD_URL +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT CONTENT_TYPE_NAME = ["content-type", "CONTENT_TYPE", "Content_Type", "conTENT_tYpe"] CONTENT_TYPE_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] -REQUEST_PATH = ["/v1/ignore", "/api/ignore"] METHODS = ["post", "put", "patch"] @pytest.mark.prodtest @pytest.mark.parametrize("content_type_name", CONTENT_TYPE_NAME) @pytest.mark.parametrize("content_type_value", CONTENT_TYPE_VALUE) -@pytest.mark.parametrize("request_path", REQUEST_PATH) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) def test_415_invalid( content_type_name, content_type_value, - request_path, correlation_id, method ): """ .. include:: ../../partials/content_types/test_415_invalid.rst """ - resp = getattr(requests, method)(f"{PROD_URL}{request_path}", headers={ + resp = getattr(requests, method)(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": f"{Authentication.generate_authentication('prod')}", "Accept": "application/json", content_type_name: content_type_value, diff --git a/tests/production/content_types/test_content_type_negotiation.py b/tests/production/message_batches/content_types/test_content_type_negotiation.py similarity index 83% rename from tests/production/content_types/test_content_type_negotiation.py rename to tests/production/message_batches/content_types/test_content_type_negotiation.py index c3604ea8d..58ce9e864 100644 --- a/tests/production/content_types/test_content_type_negotiation.py +++ b/tests/production/message_batches/content_types/test_content_type_negotiation.py @@ -2,6 +2,7 @@ import pytest from lib import Authentication, Error_Handler from lib.constants.constants import METHODS, PROD_URL +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT ACCEPT_HEADERS = [ { @@ -32,7 +33,7 @@ def test_application_response_type(accept_headers, method): """ .. include:: ../../partials/content_types/test_application_response_type.rst """ - resp = getattr(requests, method)(f"{PROD_URL}", headers={ + resp = getattr(requests, method)(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": f"{Authentication.generate_authentication('prod')}", **accept_headers.get("headers") }) diff --git a/tests/sandbox/content_types/__init__.py b/tests/production/message_batches/create_message_batches/__init__.py similarity index 100% rename from tests/sandbox/content_types/__init__.py rename to tests/production/message_batches/create_message_batches/__init__.py diff --git a/tests/production/create_message_batches/test_field_validation.py b/tests/production/message_batches/create_message_batches/test_field_validation.py similarity index 89% rename from tests/production/create_message_batches/test_field_validation.py rename to tests/production/message_batches/create_message_batches/test_field_validation.py index f051fcddc..45bfed457 100644 --- a/tests/production/create_message_batches/test_field_validation.py +++ b/tests/production/message_batches/create_message_batches/test_field_validation.py @@ -3,7 +3,8 @@ import uuid from lib import Assertions, Permutations, Generators, Authentication import lib.constants.constants as constants -from lib.constants.message_batches_paths import * +from lib.constants.message_batches_paths import MISSING_PROPERTIES_PATHS, NULL_PROPERTIES_PATHS, \ + INVALID_PROPERTIES_PATHS, DUPLICATE_PROPERTIES_PATHS, TOO_FEW_PROPERTIES_PATHS, MESSAGE_BATCHES_ENDPOINT headers = { "Accept": "application/json", @@ -21,7 +22,7 @@ def test_invalid_body(correlation_id): .. include:: ../../partials/validation/test_invalid_body.rst """ resp = requests.post( - f"{constants.PROD_URL}/v1/message-batches", + f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, @@ -49,7 +50,7 @@ def test_property_missing(property, pointer, correlation_id): .. include:: ../../partials/validation/test_property_missing.rst """ resp = requests.post( - f"{constants.PROD_URL}/v1/message-batches", + f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, @@ -80,7 +81,7 @@ def test_data_null(property, pointer, correlation_id): .. include:: ../../partials/validation/test_data_null.rst """ resp = requests.post( - f"{constants.PROD_URL}/v1/message-batches", + f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, @@ -111,7 +112,7 @@ def test_data_invalid(property, pointer, correlation_id): .. include:: ../../partials/validation/test_data_invalid.rst """ resp = requests.post( - f"{constants.PROD_URL}/v1/message-batches", + f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, @@ -148,7 +149,7 @@ def test_data_duplicate(property, pointer, correlation_id): # Post the same message a 2nd time to trigger the duplicate error resp = requests.post( - f"{constants.PROD_URL}/v1/message-batches", + f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, @@ -176,7 +177,7 @@ def test_data_too_few_items(property, pointer, correlation_id): .. include:: ../../partials/validation/test_data_too_few_items.rst """ resp = requests.post( - f"{constants.PROD_URL}/v1/message-batches", + f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, @@ -204,7 +205,7 @@ def test_invalid_nhs_number(nhs_number, correlation_id): """ .. include:: ../../partials/validation/test_invalid_nhs_number.rst """ - resp = requests.post(f"{constants.PROD_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('prod')}" @@ -243,7 +244,7 @@ def test_invalid_dob(dob, correlation_id): """ .. include:: ../../partials/validation/test_invalid_dob.rst """ - resp = requests.post(f"{constants.PROD_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('prod')}" @@ -281,7 +282,7 @@ def test_invalid_routing_plan(correlation_id): """ .. include:: ../../partials/validation/test_invalid_routing_plan.rst """ - resp = requests.post(f"{constants.PROD_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('prod')}" @@ -319,7 +320,7 @@ def test_invalid_message_batch_reference(correlation_id): """ .. include:: ../../partials/validation/test_invalid_message_batch_reference.rst """ - resp = requests.post(f"{constants.PROD_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('prod')}" @@ -357,7 +358,7 @@ def test_invalid_message_reference(correlation_id): """ .. include:: ../../partials/validation/test_invalid_message_reference.rst """ - resp = requests.post(f"{constants.PROD_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('prod')}" @@ -396,7 +397,7 @@ def test_blank_value_under_messages(invalid_value, correlation_id): """ .. include:: ../../partials/validation/test_blank_value_under_messages.rst """ - resp = requests.post(f"{constants.PROD_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('prod')}" @@ -427,7 +428,7 @@ def test_null_value_under_messages(correlation_id): """ .. include:: ../../partials/validation/test_null_value_under_messages.rst """ - resp = requests.post(f"{constants.PROD_URL}/v1/message-batches", headers={ + resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, "Authorization": f"{Authentication.generate_authentication('prod')}" diff --git a/tests/production/create_message_batches/test_invalid_routing_config.py b/tests/production/message_batches/create_message_batches/test_invalid_routing_config.py similarity index 92% rename from tests/production/create_message_batches/test_invalid_routing_config.py rename to tests/production/message_batches/create_message_batches/test_invalid_routing_config.py index 307aed749..9ebd207e0 100644 --- a/tests/production/create_message_batches/test_invalid_routing_config.py +++ b/tests/production/message_batches/create_message_batches/test_invalid_routing_config.py @@ -3,6 +3,7 @@ import uuid from lib import Assertions, Generators, Authentication from lib.constants.constants import PROD_URL +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT CORRELATION_IDS = [None, "228aac39-542d-4803-b28e-5de9e100b9f8"] METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] @@ -17,7 +18,7 @@ def test_no_such_routing_plan(correlation_id): .. include:: ../../partials/invalid_routing_plans/test_no_such_routing_plan.rst """ - resp = requests.post(f"{PROD_URL}/v1/message-batches", headers={ + resp = requests.post(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": f"{Authentication.generate_authentication('prod')}", "X-Correlation-Id": correlation_id }, json={ @@ -54,7 +55,7 @@ def test_routing_plan_not_belonging_to_client_id(correlation_id): """ .. include:: ../../partials/invalid_routing_plans/test_routing_plan_not_belonging_to_client_id.rst """ - resp = requests.post(f"{PROD_URL}/v1/message-batches", headers={ + resp = requests.post(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": f"{Authentication.generate_authentication('prod')}", "X-Correlation-Id": correlation_id }, json={ diff --git a/tests/production/create_message_batches/test_performance.py b/tests/production/message_batches/create_message_batches/test_performance.py similarity index 85% rename from tests/production/create_message_batches/test_performance.py rename to tests/production/message_batches/create_message_batches/test_performance.py index df8f28de0..de2b1db1a 100644 --- a/tests/production/create_message_batches/test_performance.py +++ b/tests/production/message_batches/create_message_batches/test_performance.py @@ -2,7 +2,8 @@ import pytest import uuid from lib import Assertions, Generators, Authentication -from lib.constants.constants import * +from lib.constants.constants import PROD_URL, NUM_MAX_ERRORS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT NUM_MESSAGES = 50000 @@ -25,7 +26,7 @@ def test_create_messages_large_invalid_payload(): "personalisation": {} }) - resp = requests.post(f"{PROD_URL}/v1/message-batches", headers={ + resp = requests.post(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", "Content-Type": "application/json", "Authorization": f"{Authentication.generate_authentication('prod')}" @@ -54,7 +55,7 @@ def test_create_messages_large_not_unique_payload(): "personalisation": {} }) - resp = requests.post(f"{PROD_URL}/v1/message-batches", headers={ + resp = requests.post(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", "Content-Type": "application/json", "Authorization": f"{Authentication.generate_authentication('prod')}" diff --git a/tests/sandbox/create_message_batches/__init__.py b/tests/production/message_batches/headers/__init__.py similarity index 100% rename from tests/sandbox/create_message_batches/__init__.py rename to tests/production/message_batches/headers/__init__.py diff --git a/tests/production/headers/test_cors.py b/tests/production/message_batches/headers/test_cors.py similarity index 75% rename from tests/production/headers/test_cors.py rename to tests/production/message_batches/headers/test_cors.py index 5e96dd980..b358559f8 100644 --- a/tests/production/headers/test_cors.py +++ b/tests/production/message_batches/headers/test_cors.py @@ -1,7 +1,8 @@ import requests import pytest from lib import Assertions, Authentication -from lib.constants.constants import * +from lib.constants.constants import PROD_URL +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"] @@ -14,7 +15,7 @@ def test_cors_options(method): """ .. include :: ../../partials/headers/test_cors_options.rst """ - resp = requests.options(f"{PROD_URL}", headers={ + resp = requests.options(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": f"{Authentication.generate_authentication('prod')}", "Accept": "*/*", "Origin": "https://my.website", @@ -29,7 +30,7 @@ def test_cors(method): """ .. include :: ../../partials/headers/test_cors.rst """ - resp = getattr(requests, method)(f"{PROD_URL}", headers={ + resp = getattr(requests, method)(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": f"{Authentication.generate_authentication('prod')}", "Accept": "*/*", "Origin": "https://my.website" diff --git a/tests/production/headers/test_x_correlation_id.py b/tests/production/message_batches/headers/test_x_correlation_id.py similarity index 73% rename from tests/production/headers/test_x_correlation_id.py rename to tests/production/message_batches/headers/test_x_correlation_id.py index bf81555d3..f63be4c81 100644 --- a/tests/production/headers/test_x_correlation_id.py +++ b/tests/production/message_batches/headers/test_x_correlation_id.py @@ -2,24 +2,22 @@ import pytest from lib import Authentication, Error_Handler from lib.constants.constants import METHODS, PROD_URL +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT CORRELATION_IDS = [None, "a17669c8-219a-11ee-ba86-322b0407c489"] -REQUEST_PATH = ["", "/", "/api/v1/send", "/v1/message-batches", "/v1/message-batches/"] @pytest.mark.prodtest -@pytest.mark.parametrize("request_path", REQUEST_PATH) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) def test_request_with_x_correlation_id( - request_path, correlation_id, method, ): """ .. include:: ../../partials/headers/test_request_with_x_correlation_id.rst """ - resp = getattr(requests, method)(f"{PROD_URL}{request_path}", headers={ + resp = getattr(requests, method)(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": f"{Authentication.generate_authentication('prod')}", "x-correlation-id": correlation_id }) diff --git a/tests/sandbox/create_messages/__init__.py b/tests/sandbox/message_batches/__init__.py similarity index 100% rename from tests/sandbox/create_messages/__init__.py rename to tests/sandbox/message_batches/__init__.py diff --git a/tests/sandbox/headers/__init__.py b/tests/sandbox/message_batches/authentication/__init__.py similarity index 100% rename from tests/sandbox/headers/__init__.py rename to tests/sandbox/message_batches/authentication/__init__.py diff --git a/tests/sandbox/authentication/test_401_errors.py b/tests/sandbox/message_batches/authentication/test_401_errors.py similarity index 83% rename from tests/sandbox/authentication/test_401_errors.py rename to tests/sandbox/message_batches/authentication/test_401_errors.py index 5c3511492..d8de74ed7 100644 --- a/tests/sandbox/authentication/test_401_errors.py +++ b/tests/sandbox/message_batches/authentication/test_401_errors.py @@ -2,6 +2,7 @@ import pytest from lib import Assertions, Generators from lib.constants.constants import CORRELATION_IDS, METHODS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT MOCK_TOKEN = { @@ -16,7 +17,7 @@ def test_401_invalid(nhsd_apim_proxy_url, correlation_id, method): """ .. include:: ../../partials/authentication/test_401_invalid.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **MOCK_TOKEN, "X-Correlation-Id": correlation_id }) @@ -36,7 +37,7 @@ def test_401_invalid_prefer(nhsd_apim_proxy_url, correlation_id, method): """ ..include:: ../../partials/authentication/test_401_invalid_prefer.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Prefer": "code=401", "X-Correlation-Id": correlation_id }) diff --git a/tests/sandbox/authentication/test_403_errors.py b/tests/sandbox/message_batches/authentication/test_403_errors.py similarity index 83% rename from tests/sandbox/authentication/test_403_errors.py rename to tests/sandbox/message_batches/authentication/test_403_errors.py index 172faf60a..467246ce2 100644 --- a/tests/sandbox/authentication/test_403_errors.py +++ b/tests/sandbox/message_batches/authentication/test_403_errors.py @@ -2,6 +2,7 @@ import pytest from lib import Assertions, Generators from lib.constants.constants import METHODS, CORRELATION_IDS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT FORBIDDEN_TOKEN = { "Authorization": "Bearer ClientNotRecognised" @@ -15,7 +16,7 @@ def test_403_forbidden(nhsd_apim_proxy_url, correlation_id, method): """ .. include:: ../../partials/authentication/test_403_forbidden.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **FORBIDDEN_TOKEN, "X-Correlation-Id": correlation_id }) @@ -35,7 +36,7 @@ def test_403_forbidden_prefer(nhsd_apim_proxy_url, correlation_id, method): """ .. include:: ../../partials/authentication/test_403_forbidden_prefer.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Prefer": "code=403", "X-Correlation-Id": correlation_id }) diff --git a/tests/sandbox/message_batches/content_types/__init__.py b/tests/sandbox/message_batches/content_types/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/sandbox/content_types/test_406_errors.py b/tests/sandbox/message_batches/content_types/test_406_errors.py similarity index 82% rename from tests/sandbox/content_types/test_406_errors.py rename to tests/sandbox/message_batches/content_types/test_406_errors.py index bb4f9d759..eccfbb77e 100644 --- a/tests/sandbox/content_types/test_406_errors.py +++ b/tests/sandbox/message_batches/content_types/test_406_errors.py @@ -1,32 +1,30 @@ import requests import pytest from lib import Assertions, Generators -from lib.constants.constants import * +from lib.constants.constants import METHODS, DEFAULT_CONTENT_TYPE +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT HEADER_NAME = ["accept", "ACCEPT", "Accept", "AcCePt"] HEADER_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] -REQUEST_PATH = ["/v1/ignore", "/api/ignore"] CORRELATION_IDS = [None, "88b10816-5d45-4992-bed0-ea685aaa0e1f"] @pytest.mark.sandboxtest @pytest.mark.parametrize("accept_header_name", HEADER_NAME) @pytest.mark.parametrize("accept_header_value", HEADER_VALUE) -@pytest.mark.parametrize("request_path", REQUEST_PATH) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) def test_406( nhsd_apim_proxy_url, accept_header_name, accept_header_value, - request_path, correlation_id, method ): """ .. include:: ../../partials/content_types/test_406.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}/{request_path}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}/{MESSAGE_BATCHES_ENDPOINT}", headers={ accept_header_name: accept_header_value, "X-Correlation-Id": correlation_id }) diff --git a/tests/sandbox/content_types/test_415_errors.py b/tests/sandbox/message_batches/content_types/test_415_errors.py similarity index 84% rename from tests/sandbox/content_types/test_415_errors.py rename to tests/sandbox/message_batches/content_types/test_415_errors.py index c2db17dab..6659b12e2 100644 --- a/tests/sandbox/content_types/test_415_errors.py +++ b/tests/sandbox/message_batches/content_types/test_415_errors.py @@ -1,10 +1,10 @@ import requests import pytest from lib import Assertions, Generators +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT CONTENT_TYPE_NAME = ["content-type", "CONTENT_TYPE", "Content_Type", "conTENT_tYpe"] CONTENT_TYPE_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] -REQUEST_PATH = ["/v1/ignore", "/api/ignore"] METHODS = ["post", "put", "patch"] CORRELATION_IDS = [None, "88b10816-5d45-4992-bed0-ea685aaa0e1f"] @@ -12,21 +12,19 @@ @pytest.mark.sandboxtest @pytest.mark.parametrize("content_type_name", CONTENT_TYPE_NAME) @pytest.mark.parametrize("content_type_value", CONTENT_TYPE_VALUE) -@pytest.mark.parametrize("request_path", REQUEST_PATH) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) def test_415_invalid( nhsd_apim_proxy_url, content_type_name, content_type_value, - request_path, correlation_id, method ): """ .. include:: ../../partials/content_types/test_415_invalid.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{request_path}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", content_type_name: content_type_value, "X-Correlation-Id": correlation_id diff --git a/tests/sandbox/content_types/test_content_negotiation.py b/tests/sandbox/message_batches/content_types/test_content_negotiation.py similarity index 79% rename from tests/sandbox/content_types/test_content_negotiation.py rename to tests/sandbox/message_batches/content_types/test_content_negotiation.py index b67f41c39..5daeaac50 100644 --- a/tests/sandbox/content_types/test_content_negotiation.py +++ b/tests/sandbox/message_batches/content_types/test_content_negotiation.py @@ -1,6 +1,7 @@ import requests import pytest from lib.constants.constants import METHODS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT from lib import Error_Handler ACCEPT_HEADERS = [ @@ -32,7 +33,8 @@ def test_application_response_type(nhsd_apim_proxy_url, accept_headers, method): """ .. include:: ../../partials/content_types/test_application_response_type.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}", headers=accept_headers.get("headers")) + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", + headers=accept_headers.get("headers")) Error_Handler.handle_retry(resp) diff --git a/tests/sandbox/message_batches/create_message_batches/__init__.py b/tests/sandbox/message_batches/create_message_batches/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/sandbox/create_message_batches/test_field_validation.py b/tests/sandbox/message_batches/create_message_batches/test_field_validation.py similarity index 91% rename from tests/sandbox/create_message_batches/test_field_validation.py rename to tests/sandbox/message_batches/create_message_batches/test_field_validation.py index 090a6b89f..9ef6ac6e3 100644 --- a/tests/sandbox/create_message_batches/test_field_validation.py +++ b/tests/sandbox/message_batches/create_message_batches/test_field_validation.py @@ -2,9 +2,9 @@ import pytest import uuid from lib import Assertions, Permutations, Generators -from lib.constants.constants import * -from lib.constants.message_batches_paths import * - +from lib.constants.constants import INVALID_NHS_NUMBER, INVALID_DOB, INVALID_MESSAGE_VALUES, NUM_MAX_ERRORS +from lib.constants.message_batches_paths import MISSING_PROPERTIES_PATHS, NULL_PROPERTIES_PATHS, \ + INVALID_PROPERTIES_PATHS, DUPLICATE_PROPERTIES_PATHS, TOO_FEW_PROPERTIES_PATHS, MESSAGE_BATCHES_ENDPOINT headers = { "Accept": "application/json", "Content-Type": "application/json" @@ -19,7 +19,7 @@ def test_invalid_body(nhsd_apim_proxy_url, correlation_id): .. include:: ../../partials/validation/test_invalid_body.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id @@ -46,7 +46,7 @@ def test_property_missing(nhsd_apim_proxy_url, property, pointer, correlation_id .. include:: ../../partials/validation/test_property_missing.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id @@ -76,7 +76,7 @@ def test_data_null(nhsd_apim_proxy_url, property, pointer, correlation_id): .. include:: ../../partials/validation/test_data_null.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id @@ -106,7 +106,7 @@ def test_data_invalid(nhsd_apim_proxy_url, property, pointer, correlation_id): .. include:: ../../partials/validation/test_data_invalid.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id @@ -142,7 +142,7 @@ def test_data_duplicate(nhsd_apim_proxy_url, property, pointer, correlation_id): # Post the same message a 2nd time to trigger the duplicate error resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id @@ -169,7 +169,7 @@ def test_data_too_few_items(nhsd_apim_proxy_url, property, pointer, correlation_ .. include:: ../../partials/validation/test_data_too_few_items.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id @@ -196,7 +196,7 @@ def test_invalid_nhs_number(nhsd_apim_proxy_url, nhs_number, correlation_id): """ .. include:: ../../partials/validation/test_invalid_nhs_number.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id }, json={ @@ -234,7 +234,7 @@ def test_invalid_dob(nhsd_apim_proxy_url, dob, correlation_id): """ .. include:: ../../partials/validation/test_invalid_dob.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id }, json={ @@ -270,7 +270,7 @@ def test_invalid_routing_plan(nhsd_apim_proxy_url, correlation_id): """ .. include:: ../../partials/validation/test_invalid_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id }, json={ @@ -307,7 +307,7 @@ def test_invalid_message_batch_reference(nhsd_apim_proxy_url, correlation_id): """ .. include:: ../../partials/validation/test_invalid_message_batch_reference.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id }, json={ @@ -344,7 +344,7 @@ def test_invalid_message_reference(nhsd_apim_proxy_url, correlation_id): """ .. include:: ../../partials/validation/test_invalid_message_reference.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id }, json={ @@ -382,7 +382,7 @@ def test_blank_value_under_messages(nhsd_apim_proxy_url, invalid_value, correlat """ .. include:: ../../partials/validation/test_blank_value_under_messages.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id }, json={ @@ -412,7 +412,7 @@ def test_null_value_under_messages(nhsd_apim_proxy_url, correlation_id): """ .. include:: ../../partials/validation/test_null_value_under_messages.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id }, json={ @@ -464,7 +464,7 @@ def test_validation_returns_at_max_errors(nhsd_apim_proxy_url, correlation_id, n } } resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id diff --git a/tests/sandbox/create_message_batches/test_invalid_routing_plan.py b/tests/sandbox/message_batches/create_message_batches/test_invalid_routing_plan.py similarity index 93% rename from tests/sandbox/create_message_batches/test_invalid_routing_plan.py rename to tests/sandbox/message_batches/create_message_batches/test_invalid_routing_plan.py index 75c967930..8307881f7 100644 --- a/tests/sandbox/create_message_batches/test_invalid_routing_plan.py +++ b/tests/sandbox/message_batches/create_message_batches/test_invalid_routing_plan.py @@ -2,6 +2,7 @@ import pytest import uuid from lib import Assertions, Generators +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT CORRELATION_IDS = [None, "228aac39-542d-4803-b28e-5de9e100b9f8"] @@ -16,7 +17,7 @@ def test_no_such_routing_plan(nhsd_apim_proxy_url, correlation_id): """ .. include:: ../../partials/invalid_routing_plans/test_no_such_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "X-Correlation-Id": correlation_id }, json={ "data": { @@ -52,7 +53,7 @@ def test_invalid_routing_plan(nhsd_apim_proxy_url, correlation_id): """ .. include:: ../../partials/invalid_routing_plans/test_invalid_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "X-Correlation-Id": correlation_id }, json={ "data": { @@ -88,7 +89,7 @@ def test_500_duplicate_routing_plan(nhsd_apim_proxy_url, correlation_id): """ .. include:: ../../partials/invalid_routing_plans/test_500_duplicate_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "X-Correlation-Id": correlation_id }, json={ "data": { @@ -149,7 +150,7 @@ def test_500_missing_routing_plan(nhsd_apim_proxy_url, correlation_id, routing_p """ .. include:: ../../partials/invalid_routing_plans/test_500_missing_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "X-Correlation-Id": correlation_id }, json={ "data": { diff --git a/tests/sandbox/create_message_batches/test_performance.py b/tests/sandbox/message_batches/create_message_batches/test_performance.py similarity index 89% rename from tests/sandbox/create_message_batches/test_performance.py rename to tests/sandbox/message_batches/create_message_batches/test_performance.py index 663a1c01b..3988d7f97 100644 --- a/tests/sandbox/create_message_batches/test_performance.py +++ b/tests/sandbox/message_batches/create_message_batches/test_performance.py @@ -3,6 +3,7 @@ import uuid from lib import Assertions, Generators from lib.constants.constants import NUM_MAX_ERRORS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT NUM_MESSAGES = 50000 @@ -25,7 +26,7 @@ def test_create_messages_large_valid_payload(nhsd_apim_proxy_url): "personalisation": {} }) - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", "Content-Type": "application/json" }, json=data @@ -51,7 +52,7 @@ def test_create_messages_large_invalid_payload(nhsd_apim_proxy_url): "personalisation": {} }) - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", "Content-Type": "application/json" }, json=data @@ -79,7 +80,7 @@ def test_create_messages_large_not_unique_payload(nhsd_apim_proxy_url): "personalisation": {} }) - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/message-batches", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", "Content-Type": "application/json" }, json=data diff --git a/tests/sandbox/create_message_batches/test_retry_too_early.py b/tests/sandbox/message_batches/create_message_batches/test_retry_too_early.py similarity index 94% rename from tests/sandbox/create_message_batches/test_retry_too_early.py rename to tests/sandbox/message_batches/create_message_batches/test_retry_too_early.py index 3189b1d71..2564219bb 100644 --- a/tests/sandbox/create_message_batches/test_retry_too_early.py +++ b/tests/sandbox/message_batches/create_message_batches/test_retry_too_early.py @@ -3,6 +3,7 @@ import uuid from lib import Assertions, Generators from lib.constants.constants import CORRELATION_IDS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT FORBIDDEN_TOKEN = {"Authorization": "Bearer ClientNotRecognised"} TRIGGER_425_ROUTING_CONFIG_ID = "d895ade5-0029-4fc3-9fb5-86e1e5370854" @@ -28,7 +29,7 @@ def test_425_retry_too_early(nhsd_apim_proxy_url, correlation_id): """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Content-Type": "application/json", "X-Correlation-Id": correlation_id, @@ -80,7 +81,7 @@ def test_prefer_425_retry_too_early(nhsd_apim_proxy_url, correlation_id): """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Prefer": "code=425", "Content-Type": "application/json", diff --git a/tests/sandbox/create_message_batches/test_service_ban.py b/tests/sandbox/message_batches/create_message_batches/test_service_ban.py similarity index 89% rename from tests/sandbox/create_message_batches/test_service_ban.py rename to tests/sandbox/message_batches/create_message_batches/test_service_ban.py index 5cad0bff6..c310eb08d 100644 --- a/tests/sandbox/create_message_batches/test_service_ban.py +++ b/tests/sandbox/message_batches/create_message_batches/test_service_ban.py @@ -2,6 +2,7 @@ import pytest from lib import Assertions, Generators from lib.constants.constants import CORRELATION_IDS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT FORBIDDEN_TOKEN = { "Authorization": "Bearer ClientNotRecognised" @@ -16,7 +17,7 @@ def test_403_service_ban(nhsd_apim_proxy_url, correlation_id): """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": "banned", "Content-Type": "application/json", @@ -42,7 +43,7 @@ def test_prefer_403_service_ban(nhsd_apim_proxy_url, correlation_id): """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/message-batches", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Prefer": "code=403.1", "Content-Type": "application/json", diff --git a/tests/sandbox/create_message_batches/test_success.py b/tests/sandbox/message_batches/create_message_batches/test_success.py similarity index 87% rename from tests/sandbox/create_message_batches/test_success.py rename to tests/sandbox/message_batches/create_message_batches/test_success.py index be139e4bb..293e88230 100644 --- a/tests/sandbox/create_message_batches/test_success.py +++ b/tests/sandbox/message_batches/create_message_batches/test_success.py @@ -2,8 +2,8 @@ import pytest from lib import Assertions, Generators import lib.constants.constants as constants +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT -REQUEST_PATH = "/v1/message-batches" VALID_ROUTING_PLAN_ID = [ "b838b13c-f98c-4def-93f0-515d4e4f4ee1", "49e43b98-70cb-47a9-a55e-fe70c9a6f77c", @@ -21,7 +21,7 @@ def test_201_message_batch_valid_accept_headers(nhsd_apim_proxy_url, accept_head """ data = Generators.generate_valid_create_message_batch_body("sandbox") resp = requests.post( - f"{nhsd_apim_proxy_url}{REQUEST_PATH}", + f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": accept_headers, "Content-Type": "application/json" @@ -38,7 +38,7 @@ def test_201_message_batch_valid_content_type_headers(nhsd_apim_proxy_url, conte .. include:: ../../partials/happy_path/test_201_message_batch_valid_content_type_headers.rst """ data = Generators.generate_valid_create_message_batch_body("sandbox") - resp = requests.post(f"{nhsd_apim_proxy_url}{REQUEST_PATH}", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", "Content-Type": content_type }, json=data @@ -55,7 +55,7 @@ def test_201_message_batch_valid_routing_plan_id(nhsd_apim_proxy_url, routing_pl data = Generators.generate_valid_create_message_batch_body("sandbox") data["data"]["attributes"]["routingPlanId"] = routing_plan_id - resp = requests.post(f"{nhsd_apim_proxy_url}{REQUEST_PATH}", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", "Content-Type": "application/json" }, json=data @@ -71,7 +71,7 @@ def test_201_message_batch_valid_nhs_number(nhsd_apim_proxy_url): data = Generators.generate_valid_create_message_batch_body("sandbox") data["data"]["attributes"]["messages"][0]["recipient"]["nhsNumber"] = constants.VALID_NHS_NUMBER - resp = requests.post(f"{nhsd_apim_proxy_url}{REQUEST_PATH}", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", "Content-Type": "application/json" }, json=data @@ -88,7 +88,7 @@ def test_201_message_batch_valid_dob(nhsd_apim_proxy_url, dob): data = Generators.generate_valid_create_message_batch_body("sandbox") data["data"]["attributes"]["messages"][0]["recipient"]["dateOfBirth"] = dob - resp = requests.post(f"{nhsd_apim_proxy_url}{REQUEST_PATH}", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", "Content-Type": "application/json" }, json=data @@ -104,7 +104,7 @@ def test_request_without_dob(nhsd_apim_proxy_url): data = Generators.generate_valid_create_message_batch_body("sandbox") data["data"]["attributes"]["messages"][0]["recipient"].pop("dateOfBirth") - resp = requests.post(f"{nhsd_apim_proxy_url}{REQUEST_PATH}", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", "Content-Type": "application/json" }, json=data diff --git a/tests/sandbox/message_batches/headers/__init__.py b/tests/sandbox/message_batches/headers/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/sandbox/headers/test_cors.py b/tests/sandbox/message_batches/headers/test_cors.py similarity index 76% rename from tests/sandbox/headers/test_cors.py rename to tests/sandbox/message_batches/headers/test_cors.py index a9097911a..c47eb8d79 100644 --- a/tests/sandbox/headers/test_cors.py +++ b/tests/sandbox/message_batches/headers/test_cors.py @@ -1,6 +1,7 @@ import requests import pytest from lib import Assertions +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"] @@ -13,7 +14,7 @@ def test_cors_options(nhsd_apim_proxy_url, method): """ .. include :: ../../partials/headers/test_cors_options.rst """ - resp = requests.options(f"{nhsd_apim_proxy_url}", headers={ + resp = requests.options(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "*/*", "Origin": "https://my.website", "Access-Control-Request-Method": method @@ -27,7 +28,7 @@ def test_cors(nhsd_apim_proxy_url, method): """ .. include :: ../../partials/headers/test_cors.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "*/*", "Origin": "https://my.website" }) diff --git a/tests/sandbox/headers/test_x_correlation_id.py b/tests/sandbox/message_batches/headers/test_x_correlation_id.py similarity index 68% rename from tests/sandbox/headers/test_x_correlation_id.py rename to tests/sandbox/message_batches/headers/test_x_correlation_id.py index b8d4c8006..941436a4d 100644 --- a/tests/sandbox/headers/test_x_correlation_id.py +++ b/tests/sandbox/message_batches/headers/test_x_correlation_id.py @@ -1,25 +1,22 @@ import requests import pytest from lib.constants.constants import CORRELATION_IDS, METHODS +from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT from lib import Error_Handler -REQUEST_PATH = ["", "/", "/api/v1/send", "/v1/message-batches", "/v1/message-batches/"] - @pytest.mark.sandboxtest -@pytest.mark.parametrize("request_path", REQUEST_PATH) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) def test_request_with_x_correlation_id( nhsd_apim_proxy_url, - request_path, correlation_id, method ): """ .. include:: ../../partials/headers/test_request_with_x_correlation_id.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{request_path}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "x-correlation-id": correlation_id }) diff --git a/tests/sandbox/messages/__init__.py b/tests/sandbox/messages/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/sandbox/messages/create_messages/__init__.py b/tests/sandbox/messages/create_messages/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/sandbox/create_messages/test_field_validation.py b/tests/sandbox/messages/create_messages/test_field_validation.py similarity index 91% rename from tests/sandbox/create_messages/test_field_validation.py rename to tests/sandbox/messages/create_messages/test_field_validation.py index 09326fa31..28b2ddafe 100644 --- a/tests/sandbox/create_messages/test_field_validation.py +++ b/tests/sandbox/messages/create_messages/test_field_validation.py @@ -2,8 +2,9 @@ import pytest import uuid from lib import Assertions, Permutations, Generators -from lib.constants.constants import * -from lib.constants.messages_paths import * +from lib.constants.messages_paths import MISSING_PROPERTIES_PATHS, NULL_PROPERTIES_PATHS, \ + INVALID_PROPERTIES_PATHS, MESSAGES_ENDPOINT + headers = { "Accept": "application/json", @@ -21,7 +22,7 @@ def test_invalid_body(nhsd_apim_proxy_url, correlation_id): .. include:: ../../partials/validation/test_invalid_body.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/messages", + f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id @@ -48,7 +49,7 @@ def test_property_missing(nhsd_apim_proxy_url, property, pointer, correlation_id .. include:: ../../partials/validation/test_property_missing.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/messages", + f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id @@ -78,7 +79,7 @@ def test_data_null(nhsd_apim_proxy_url, property, pointer, correlation_id): .. include:: ../../partials/validation/test_data_null.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/messages", + f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id @@ -108,7 +109,7 @@ def test_data_invalid(nhsd_apim_proxy_url, property, pointer, correlation_id): .. include:: ../../partials/validation/test_data_invalid.rst """ resp = requests.post( - f"{nhsd_apim_proxy_url}/v1/messages", + f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id @@ -135,7 +136,7 @@ def test_invalid_nhs_number(nhsd_apim_proxy_url, nhs_number, correlation_id): """ .. include:: ../../partials/validation/test_invalid_nhs_number.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/messages", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id }, json={ @@ -169,7 +170,7 @@ def test_invalid_dob(nhsd_apim_proxy_url, dob, correlation_id): """ .. include:: ../../partials/validation/test_invalid_dob.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/messages", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id }, json={ @@ -202,7 +203,7 @@ def test_invalid_routing_plan(nhsd_apim_proxy_url, correlation_id): """ .. include:: ../../partials/validation/test_invalid_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/messages", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id }, json={ @@ -235,7 +236,7 @@ def test_invalid_message_reference(nhsd_apim_proxy_url, correlation_id): """ .. include:: ../../partials/validation/test_invalid_message_reference.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/messages", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id }, json={ diff --git a/tests/sandbox/create_messages/test_invalid_routing_plan.py b/tests/sandbox/messages/create_messages/test_invalid_routing_plan.py similarity index 92% rename from tests/sandbox/create_messages/test_invalid_routing_plan.py rename to tests/sandbox/messages/create_messages/test_invalid_routing_plan.py index 0abc9450b..2cff1ba79 100644 --- a/tests/sandbox/create_messages/test_invalid_routing_plan.py +++ b/tests/sandbox/messages/create_messages/test_invalid_routing_plan.py @@ -2,6 +2,7 @@ import pytest import uuid from lib import Assertions, Generators +from lib.constants.messages_paths import MESSAGES_ENDPOINT CORRELATION_IDS = [None, "228aac39-542d-4803-b28e-5de9e100b9f8"] @@ -14,7 +15,7 @@ def test_500_routing_plan_with_duplicate_templates(nhsd_apim_proxy_url, correlat """ .. include:: ../../partials/invalid_routing_plans/test_500_duplicate_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/messages", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ "X-Correlation-Id": correlation_id }, json={ "data": { @@ -70,7 +71,7 @@ def test_500_routing_plan_with_missing_template(nhsd_apim_proxy_url, correlation """ .. include:: ../../partials/invalid_routing_plans/test_500_missing_routing_plan.rst """ - resp = requests.post(f"{nhsd_apim_proxy_url}/v1/messages", headers={ + resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ "X-Correlation-Id": correlation_id }, json={ "data": {