diff --git a/application/common/constants.py b/application/common/constants.py index b0fed13ce..5cd5d870d 100644 --- a/application/common/constants.py +++ b/application/common/constants.py @@ -3,7 +3,7 @@ CLOSED_AND_HIDDEN_STATUSES = ["HIDDEN", "CLOSED"] PHARMACY_SERVICE_TYPE_IDS = [13, 131, 132, 134, 137, 148, 149] -PHARMACY_ORGANISATION_SUB_TYPES = ["Community"] +PHARMACY_ORGANISATION_SUB_TYPES = ["Community", "DistanceSelling"] PHARMACY_ODSCODE_LENGTH = 5 PHARMACY_SERVICE_TYPE_ID = 13 diff --git a/test/integration/features/F001_Valid_Change_Events.feature b/test/integration/features/F001_Valid_Change_Events.feature index 004786dff..f4db2d5d5 100644 --- a/test/integration/features/F001_Valid_Change_Events.feature +++ b/test/integration/features/F001_Valid_Change_Events.feature @@ -513,3 +513,51 @@ Feature: F001. Ensure valid change events are converted and sent to DoS | " 0123456789" | 0123456789 | | "0123456789 " | 0123456789 | | "012 34567 89" | 0123456789 | + + + @complete @general + Scenario Outline: F001SX40. Changes are processed successfully for service_type = "134" with OrganisationSubType = "DistanceSelling" + Given an entry is created in the services table + And the service "service_type" is set to "134" + And the service "service_status" is set to "1" + And the entry is committed to the services table + And the change event "OrganisationSubType" is set to "DistanceSelling" + When the Changed Event is sent for processing with "valid" api key + Then the "service-sync" lambda shows field "message" with value "Update Request Success" + Then the Changed Event is stored in dynamo db + And the service history is not updated + When the change event "" is set to "" + When the Changed Event is sent for processing with "valid" api key + Then the Changed Event is stored in dynamo db + Then the "" is updated within the DoS DB + And the service history shows "" change type is "modify" + + Examples: + | field | value | DOS_field |service_hist_field | + | website | www.testonetwo.com | website | cmsurl | + | phone | 22459436909 | phone | cmstelephoneno | + | Address1 | 5 Tester Way | address | postaladdress | + + @complete @general + Scenario: F001SX41. Changed Event with updated postcode to verify location changes with service_type = "134" and OrganisationSubType = "DistanceSelling" + Given an entry is created in the services table + And the service "service_type" is set to "134" + And the service "service_status" is set to "1" + And the entry is committed to the services table + And the change event "OrganisationSubType" is set to "DistanceSelling" + When the Changed Event is sent for processing with "valid" api key + Then the "service-sync" lambda shows field "message" with value "Update Request Success" + Then the Changed Event is stored in dynamo db + And the service history is not updated + When the change event "Postcode" is set to "PR4 2BE" + When the Changed Event is sent for processing with "valid" api key + Then the Changed Event is stored in dynamo db + Then DoS has "PR4 2BE" in the "Postcode" field + Then DoS has "KIRKHAM" in the "town" field + And DoS has "341832" in the "easting" field + And DoS has "432011" in the "northing" field + And DoS has "53.781108" in the "latitude" field + And DoS has "-2.886537" in the "longitude" field + And the service history is updated with the "Postcode" + And the service history shows "postalcode" change type is "modify" + diff --git a/test/integration/features/F002_Invalid_Change_Events.feature b/test/integration/features/F002_Invalid_Change_Events.feature index 4a2eed3cb..fb2334910 100644 --- a/test/integration/features/F002_Invalid_Change_Events.feature +++ b/test/integration/features/F002_Invalid_Change_Events.feature @@ -62,3 +62,11 @@ Feature: F002. Invalid change event Exception handling And the change event has an additional date with no specified date When the Changed Event is sent for processing with "valid" api key Then the "service-sync" lambda shows field "message" with value "Opening times are not valid" + + @complete @validation + Scenario: F002SXX9. A Changed Event where OrganisationSubType is NOT DistanceSelling is reported and ignored + Given a basic service is created with type "134" + And the change event "OrganisationSubType" is set to "Distance Selling" + When the Changed Event is sent for processing with "valid" api key + Then the "ingest-change-event" lambda shows field "message" with value "Validation Error - Unexpected Org Sub Type ID: 'Distance Selling'" + And the service history is not updated diff --git a/test/integration/features/F005_Support_Functions.feature b/test/integration/features/F005_Support_Functions.feature index 88e9e5a10..20b717330 100644 --- a/test/integration/features/F005_Support_Functions.feature +++ b/test/integration/features/F005_Support_Functions.feature @@ -7,6 +7,14 @@ Feature: F005. Support Functions Then the Changed Event is stored in dynamo db And the stored Changed Event is reprocessed in DI + @complete @general + Scenario: F005SXX1. An unprocessed Changed Event with service_type = "134" and OrganisationSubType = "DistanceSelling" is replayed in DI + Given a basic service is created with type "134" + And the change event "OrganisationSubType" is set to "DistanceSelling" + When the Changed Event is sent for processing with "valid" api key + Then the Changed Event is stored in dynamo db + And the stored Changed Event is reprocessed in DI + @complete @slack_and_infrastructure Scenario: F005SXX2 SQS Message for Change Event DLQ Alert Given a basic service is created diff --git a/test/integration/features/F006_Opening_Times.feature b/test/integration/features/F006_Opening_Times.feature index e487c3715..f592daecc 100644 --- a/test/integration/features/F006_Opening_Times.feature +++ b/test/integration/features/F006_Opening_Times.feature @@ -79,3 +79,17 @@ Feature: F006. Opening times When the Changed Event is sent for processing with "valid" api key Then DoS is open from "10:00" until "16:00" on "Jan 01 2025" And the "service-sync" lambda does not show "report_key" with value "BLANK_STANDARD_OPENINGS" + + @complete @opening_times + Scenario: F006SXX11. Confirm actual opening times change for specified date and time is captured by DoS with service_type = "134" and OrganisationSubType = "DistanceSelling" + Given a basic service is created with type "134" + And the change event "OrganisationSubType" is set to "DistanceSelling" + When the Changed Event is sent for processing with "valid" api key + Then the "service-sync" lambda shows field "message" with value "Update Request Success" + Then the Changed Event is stored in dynamo db + And the service history is not updated + When the change event is "open" on date "Dec 25 2028" + When the Changed Event is sent for processing with "valid" api key + Then the Changed Event is stored in dynamo db + Then the DoS service has been updated with the specified date is captured by DoS + And the service history is updated with the "added" specified opening times diff --git a/test/integration/steps/functions/dos/get_data.py b/test/integration/steps/functions/dos/get_data.py index 051c436fb..55e0764c9 100644 --- a/test/integration/steps/functions/dos/get_data.py +++ b/test/integration/steps/functions/dos/get_data.py @@ -60,17 +60,18 @@ def get_services_table_location_data(service_id: str) -> list: return loads(loads(response)) -def get_service_id(odscode: str) -> str: +def get_service_id(odscode: str, typeid: int = 13) -> str: """Get service id. Args: odscode (str): ODSCode. + typeid (int, optional): Type ID. Defaults to 13. If not provided, the default value is 13. Returns: str: Service id. """ data = [] - query = f"SELECT id FROM services WHERE typeid = 13 AND statusid = 1 AND odscode like '{odscode}%' LIMIT 1" # noqa: S608 + query = f"SELECT id FROM services WHERE typeid = {typeid} AND statusid = 1 AND odscode like '{odscode}%' LIMIT 1" # noqa: S608 for _ in range(16): lambda_payload = {"type": "read", "query": query, "query_vars": None} response = invoke_dos_db_handler_lambda(lambda_payload) diff --git a/test/integration/steps/functions/utils.py b/test/integration/steps/functions/utils.py index d3d15c661..be5b2cf21 100644 --- a/test/integration/steps/functions/utils.py +++ b/test/integration/steps/functions/utils.py @@ -80,10 +80,10 @@ def get_expected_data(context: Context, changed_data_name: str) -> Any: """Get the previous data from the context.""" match changed_data_name.lower(): case "phone_no" | "phone" | "public_phone" | "publicphone": - changed_data = context.phone + changed_data = context.generator_data["publicphone"] case "website" | "web": - changed_data = context.website - case "address": + changed_data = context.generator_data["web"] + case "address" | "address1": changed_data = get_address_string(context) case "postcode": changed_data = context.change_event["Postcode"] diff --git a/test/integration/steps/test_steps.py b/test/integration/steps/test_steps.py index c8c4a6566..22e82b410 100644 --- a/test/integration/steps/test_steps.py +++ b/test/integration/steps/test_steps.py @@ -259,7 +259,7 @@ def create_basic_service_entry(context: Context) -> Context: return service_table_entry_is_committed(context) -@given(parse('a pharmacy service is created with type "{service_type:d}"'), target_fixture="context") +@given(parse('a {service_name} service is created with type "{service_type:d}"'), target_fixture="context") def _(context: Context, service_type: int) -> Context: """Create a basic service with a specific service type. @@ -817,6 +817,38 @@ def change_event_with_blank_opening_times(context: Context) -> Context: return context +@when(parse('the change event is "{service_status}" on date "{date}"'), target_fixture="context") +def change_event_specified_opening(service_status: str, date: str, context: Context) -> Context: + """Set the change event specified opening times. + + Args: + service_status (str): The service status to set. + date (str): The date to set the service status for. + context (Context): The context object. + + Returns: + Context: The context object. + """ + query_specified_opening_builder(context, service_status, date) + context.change_event["OpeningTimes"] = build_change_event_opening_times(context) + return context + + +@when(parse('the change event "{field_name}" is set to "{values}"'), target_fixture="context") +def _(field_name: str, values: str, context: Context) -> Context: + """Update the change event values in the context. + + Args: + field_name (str): The field name to update. + values (str): The values to update the field with. + context (Context): The context object. + + Returns: + Context: The context object. + """ + return ce_values_updated_in_context(field_name, values, context) + + @when(parse('a "{queue_type}" SQS message is added to the queue'), target_fixture="context") def post_an_sqs_message(queue_type: str, context: Context) -> None: """Post an SQS message to the queue. @@ -1167,6 +1199,24 @@ def the_dos_service_has_been_updated_with_the_specified_date_and_time_is_capture assert current_specified_openings[expected_opening_date][0]["end_time"] == closing_time +@then("the DoS service has been updated with the specified date is captured by DoS") +def the_dos_service_has_been_updated_with_the_specified_date_is_captured_by_dos(context: Context) -> Context: + """Assert DoS service has been updated with the specified date and time is captured by DoS. + + Args: + context (Context): The context object. + + Returns: + Context: The context object. + """ + context.service_id = get_service_id(context.change_event["ODSCode"], context.generator_data["service_type"]) + wait_for_service_update(context.service_id) + changed_date = context.change_event["OpeningTimes"][-1]["AdditionalOpeningDate"] + current_specified_openings = get_change_event_specified_opening_times(context.service_id) + expected_opening_date = dt.strptime(changed_date, "%b %d %Y").strftime("%Y-%m-%d") + assert expected_opening_date in current_specified_openings, "DoS not updated with specified opening time" + + @then(parse('the DoS DB has no open date in "{year}"')) def the_dos_service_has_no_past_openings(context: Context, year: str) -> None: """Assert DoS service has no past openings.