From 49919123e6a828b60f682532977f4c79d8221b25 Mon Sep 17 00:00:00 2001 From: ManithaSrinivasa Date: Wed, 20 Nov 2024 13:02:07 +0000 Subject: [PATCH] Added test cases --- .../features/F001_Valid_Change_Events.feature | 35 +++++++++++++++--- .../features/F005_Support_Functions.feature | 8 +++++ .../features/F006_Opening_Times.feature | 14 ++++++++ .../steps/functions/dos/get_data.py | 5 +-- test/integration/steps/functions/utils.py | 2 +- test/integration/steps/test_steps.py | 36 +++++++++++++++++++ 6 files changed, 92 insertions(+), 8 deletions(-) diff --git a/test/integration/features/F001_Valid_Change_Events.feature b/test/integration/features/F001_Valid_Change_Events.feature index 95796b30e..baa4ab910 100644 --- a/test/integration/features/F001_Valid_Change_Events.feature +++ b/test/integration/features/F001_Valid_Change_Events.feature @@ -524,15 +524,40 @@ Feature: F001. Ensure valid change events are converted and sent to DoS 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 is updated with the "" And the service history shows "" change type is "modify" Examples: - | field | value | DOS_field |service_hist_field | - | Postcode | CT1 1AA | Postcode | postalcode | - | website | www.testonetwo.com | website | cmsurl | - | phone | 22459436909 | phone | cmstelephoneno | + | 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/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..9b5161d52 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 334d015cf..be5b2cf21 100644 --- a/test/integration/steps/functions/utils.py +++ b/test/integration/steps/functions/utils.py @@ -83,7 +83,7 @@ def get_expected_data(context: Context, changed_data_name: str) -> Any: changed_data = context.generator_data["publicphone"] case "website" | "web": changed_data = context.generator_data["web"] - case "address": + 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 ca36c76fc..7c3bad065 100644 --- a/test/integration/steps/test_steps.py +++ b/test/integration/steps/test_steps.py @@ -817,6 +817,23 @@ 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. @@ -1182,6 +1199,25 @@ 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"]) + print("service.id======>", context.service_id) + 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.