From 254fd8bb5b733e5b5c09b3d84e5e04f7dc5d0883 Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Thu, 31 Oct 2024 11:40:10 +0000 Subject: [PATCH 01/23] Test commit for build --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d3c0e795..4fa498e46 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # DoS Integration - +test ## Table of Contents - [DoS Integration](#dos-integration) From 66a4834399f9bd7a2482311b7adaa902309707a0 Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Thu, 31 Oct 2024 13:20:44 +0000 Subject: [PATCH 02/23] Added new sub type constant --- application/common/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/common/constants.py b/application/common/constants.py index b0fed13ce..60b3e2415 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", "Distance Selling"] PHARMACY_ODSCODE_LENGTH = 5 PHARMACY_SERVICE_TYPE_ID = 13 From e06b244962039fa6141217bd0c9809dce30c8250 Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Fri, 1 Nov 2024 09:10:34 +0000 Subject: [PATCH 03/23] Changed constant spelling --- application/common/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/common/constants.py b/application/common/constants.py index 60b3e2415..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", "Distance Selling"] +PHARMACY_ORGANISATION_SUB_TYPES = ["Community", "DistanceSelling"] PHARMACY_ODSCODE_LENGTH = 5 PHARMACY_SERVICE_TYPE_ID = 13 From e06ee52a6e16143b0cf755675968a371ec82df0a Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Tue, 5 Nov 2024 10:59:30 +0000 Subject: [PATCH 04/23] Commit for deploy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fa498e46..2d3c0e795 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # DoS Integration -test + ## Table of Contents - [DoS Integration](#dos-integration) From 5e24897e1fe65cbb8a8d81ccbf7932d5bb5ab25e Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Tue, 5 Nov 2024 14:39:15 +0000 Subject: [PATCH 05/23] Commit for deploy --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2d3c0e795..ce557d454 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # DoS Integration + ## Table of Contents - [DoS Integration](#dos-integration) From c5bb557d0dbb96d7a5c34126a6885b3f62011ca5 Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Wed, 6 Nov 2024 11:38:58 +0000 Subject: [PATCH 06/23] Added more logging --- application/ingest_change_event/change_event_validation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/application/ingest_change_event/change_event_validation.py b/application/ingest_change_event/change_event_validation.py index 6e5964e61..1b01c4359 100644 --- a/application/ingest_change_event/change_event_validation.py +++ b/application/ingest_change_event/change_event_validation.py @@ -58,6 +58,7 @@ def validate_organisation_keys(org_type_id: str, org_sub_type: str) -> None: ValidationError: Either Org Type ID or Org Sub Type is not part of the valid list """ validate_organisation_type_id(org_type_id) + logger.info("test log: "+ PHARMACY_ORGANISATION_SUB_TYPES) if org_sub_type in PHARMACY_ORGANISATION_SUB_TYPES: logger.info(f"Subtype type id: {org_sub_type} validated") else: From 94d6fd073c097803a61a891d5329a522046dd8d4 Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Wed, 6 Nov 2024 13:09:48 +0000 Subject: [PATCH 07/23] Added more logging --- application/ingest_change_event/change_event_validation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/ingest_change_event/change_event_validation.py b/application/ingest_change_event/change_event_validation.py index 1b01c4359..c0269cf3e 100644 --- a/application/ingest_change_event/change_event_validation.py +++ b/application/ingest_change_event/change_event_validation.py @@ -58,7 +58,8 @@ def validate_organisation_keys(org_type_id: str, org_sub_type: str) -> None: ValidationError: Either Org Type ID or Org Sub Type is not part of the valid list """ validate_organisation_type_id(org_type_id) - logger.info("test log: "+ PHARMACY_ORGANISATION_SUB_TYPES) + logger.info("test log: ", len(PHARMACY_ORGANISATION_SUB_TYPES)) + logger.info("test log: ", PHARMACY_ORGANISATION_SUB_TYPES) if org_sub_type in PHARMACY_ORGANISATION_SUB_TYPES: logger.info(f"Subtype type id: {org_sub_type} validated") else: From 59588c9ca60be45f24e390fb6d9527ebaeb8cc63 Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Wed, 6 Nov 2024 14:46:40 +0000 Subject: [PATCH 08/23] Added more logging --- application/ingest_change_event/change_event_validation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/ingest_change_event/change_event_validation.py b/application/ingest_change_event/change_event_validation.py index c0269cf3e..0aec824e2 100644 --- a/application/ingest_change_event/change_event_validation.py +++ b/application/ingest_change_event/change_event_validation.py @@ -58,8 +58,8 @@ def validate_organisation_keys(org_type_id: str, org_sub_type: str) -> None: ValidationError: Either Org Type ID or Org Sub Type is not part of the valid list """ validate_organisation_type_id(org_type_id) - logger.info("test log: ", len(PHARMACY_ORGANISATION_SUB_TYPES)) - logger.info("test log: ", PHARMACY_ORGANISATION_SUB_TYPES) + #logger.info("test log: ", len(PHARMACY_ORGANISATION_SUB_TYPES)) + #logger.info("test log: ", PHARMACY_ORGANISATION_SUB_TYPES) if org_sub_type in PHARMACY_ORGANISATION_SUB_TYPES: logger.info(f"Subtype type id: {org_sub_type} validated") else: From 664187e251a66df882506aacb06d7b6602a362d0 Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Mon, 11 Nov 2024 13:59:49 +0000 Subject: [PATCH 09/23] More logging to sync --- application/service_sync/service_sync.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/application/service_sync/service_sync.py b/application/service_sync/service_sync.py index 880603ad0..0f4acc902 100644 --- a/application/service_sync/service_sync.py +++ b/application/service_sync/service_sync.py @@ -54,6 +54,10 @@ def lambda_handler(event: SQSEvent, context: LambdaContext) -> None: # noqa: AR nhs_entity=nhs_entity, service_histories=service_histories, ) + logger.warning("TEST LOG ", nhs_entity.org_sub_type + ) + logger.warning("TEST LOG ", changes_to_dos + ) # Update Service History with changes to be made service_histories = changes_to_dos.service_histories # Update DoS data From 6c295123f2512d8129512f8618307dd4e0717e7e Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Mon, 11 Nov 2024 14:32:33 +0000 Subject: [PATCH 10/23] More logging to sync --- application/service_sync/service_sync.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application/service_sync/service_sync.py b/application/service_sync/service_sync.py index 0f4acc902..e354e1ecc 100644 --- a/application/service_sync/service_sync.py +++ b/application/service_sync/service_sync.py @@ -54,10 +54,10 @@ def lambda_handler(event: SQSEvent, context: LambdaContext) -> None: # noqa: AR nhs_entity=nhs_entity, service_histories=service_histories, ) - logger.warning("TEST LOG ", nhs_entity.org_sub_type - ) - logger.warning("TEST LOG ", changes_to_dos - ) + logger.info("TEST LOG ", nhs_entity.org_sub_type) + logger.info("TEST LOG ", changes_to_dos) + logger.warning("TOM TEST LOG", nhs_entity.org_sub_type, + cloudwatch_metric_filter_matching_attribute="UpdateRequestSuccess") # Update Service History with changes to be made service_histories = changes_to_dos.service_histories # Update DoS data From cc3d128b02a3d8fe28c5f82647d6f56340d17a74 Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Mon, 11 Nov 2024 15:03:09 +0000 Subject: [PATCH 11/23] More logging to sync --- application/service_sync/service_sync.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/application/service_sync/service_sync.py b/application/service_sync/service_sync.py index e354e1ecc..3cd2ee911 100644 --- a/application/service_sync/service_sync.py +++ b/application/service_sync/service_sync.py @@ -54,10 +54,16 @@ def lambda_handler(event: SQSEvent, context: LambdaContext) -> None: # noqa: AR nhs_entity=nhs_entity, service_histories=service_histories, ) - logger.info("TEST LOG ", nhs_entity.org_sub_type) - logger.info("TEST LOG ", changes_to_dos) + if (nhs_entity is None):{ + logger.info("NHS ENTITY IS NONE") + } + + logger.info("TEST LOG", nhs_entity.org_sub_type) + logger.info("TEST LOG", changes_to_dos) logger.warning("TOM TEST LOG", nhs_entity.org_sub_type, - cloudwatch_metric_filter_matching_attribute="UpdateRequestSuccess") + environment=getenv("ENVIRONMENT"), + cloudwatch_metric_filter_matching_attribute="UpdateRequestSuccess" + ) # Update Service History with changes to be made service_histories = changes_to_dos.service_histories # Update DoS data From bb0bc06b82c8c05eb64c6df50997254cfe48f3b5 Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Mon, 11 Nov 2024 15:33:40 +0000 Subject: [PATCH 12/23] More logging to sync --- application/service_sync/service_sync.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/application/service_sync/service_sync.py b/application/service_sync/service_sync.py index 3cd2ee911..cdf323e1f 100644 --- a/application/service_sync/service_sync.py +++ b/application/service_sync/service_sync.py @@ -58,12 +58,8 @@ def lambda_handler(event: SQSEvent, context: LambdaContext) -> None: # noqa: AR logger.info("NHS ENTITY IS NONE") } - logger.info("TEST LOG", nhs_entity.org_sub_type) - logger.info("TEST LOG", changes_to_dos) - logger.warning("TOM TEST LOG", nhs_entity.org_sub_type, - environment=getenv("ENVIRONMENT"), - cloudwatch_metric_filter_matching_attribute="UpdateRequestSuccess" - ) + logger.info(f"TEST LOG {nhs_entity.org_sub_type}") + logger.info(f"TEST LOG {changes_to_dos}") # Update Service History with changes to be made service_histories = changes_to_dos.service_histories # Update DoS data From e249c65fd16237dce4406eb9952c6b3368d889ee Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Mon, 11 Nov 2024 15:51:21 +0000 Subject: [PATCH 13/23] More logging to sync --- .../data_processing/check_for_change.py | 23 +++++++++++++++++++ application/service_sync/service_sync.py | 6 ++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/application/service_sync/data_processing/check_for_change.py b/application/service_sync/data_processing/check_for_change.py index 0a08cb1c0..9ea5aeb4d 100644 --- a/application/service_sync/data_processing/check_for_change.py +++ b/application/service_sync/data_processing/check_for_change.py @@ -63,6 +63,10 @@ def compare_nhs_uk_and_dos_data( Returns: ChangesToDoS: ChangesToDoS class with all the flags if changes need to be made and the changes to make """ + + logger.info(f"TEST LOG {nhs_entity.org_sub_type}") + logger.warning(f"TEST LOG {nhs_entity.org_sub_type}") + # Set up the holder class changes_to_dos = ChangesToDoS(dos_service=dos_service, nhs_entity=nhs_entity, service_histories=service_histories) @@ -412,3 +416,22 @@ def status_id_change(changes_to_dos: ChangesToDoS, new_value: bool, previous_val ), ) return changes_to_dos + +def check_org_for_change(changes_to_dos: ChangesToDoS) -> ChangesToDoS: + """Compares and creates change for website if needed. + + Args: + changes_to_dos (ChangesToDoS): ChangesToDoS holder object + + Returns: + ChangesToDoS: ChangesToDoS holder object + """ + if compare_website(changes=changes_to_dos): + changes_to_dos = services_change( + changes_to_dos=changes_to_dos, + change_key=DOS_WEBSITE_CHANGE_KEY, + new_value=changes_to_dos.new_website, + previous_value=changes_to_dos.current_website, + service_table_field_name="web", + ) + return changes_to_dos diff --git a/application/service_sync/service_sync.py b/application/service_sync/service_sync.py index cdf323e1f..8d02e0483 100644 --- a/application/service_sync/service_sync.py +++ b/application/service_sync/service_sync.py @@ -54,12 +54,10 @@ def lambda_handler(event: SQSEvent, context: LambdaContext) -> None: # noqa: AR nhs_entity=nhs_entity, service_histories=service_histories, ) - if (nhs_entity is None):{ - logger.info("NHS ENTITY IS NONE") - } logger.info(f"TEST LOG {nhs_entity.org_sub_type}") - logger.info(f"TEST LOG {changes_to_dos}") + + logger.warning(f"TEST LOG {changes_to_dos}") # Update Service History with changes to be made service_histories = changes_to_dos.service_histories # Update DoS data From 24fa3f7880296402db99549ec9ccdac52a48ee8e Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Mon, 11 Nov 2024 16:08:00 +0000 Subject: [PATCH 14/23] More logging to sync --- application/service_sync/service_sync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/service_sync/service_sync.py b/application/service_sync/service_sync.py index 8d02e0483..db0462c11 100644 --- a/application/service_sync/service_sync.py +++ b/application/service_sync/service_sync.py @@ -66,7 +66,7 @@ def lambda_handler(event: SQSEvent, context: LambdaContext) -> None: # noqa: AR remove_sqs_message_from_queue(receipt_handle=record.receipt_handle) # Log custom metrics logger.warning( - "Update Request Success", + "Update Request Success TEST", latency=(time_ns() // 1000000) - int(record.message_attributes.get("message_received", {}).get("stringValue")), environment=getenv("ENVIRONMENT"), From 4c7ee62f80578a0e488d76c845c14fe6218c9ef1 Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Mon, 11 Nov 2024 16:50:52 +0000 Subject: [PATCH 15/23] More logging to sync --- application/service_sync/data_processing/check_for_change.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/application/service_sync/data_processing/check_for_change.py b/application/service_sync/data_processing/check_for_change.py index 9ea5aeb4d..ff706c31d 100644 --- a/application/service_sync/data_processing/check_for_change.py +++ b/application/service_sync/data_processing/check_for_change.py @@ -64,9 +64,6 @@ def compare_nhs_uk_and_dos_data( ChangesToDoS: ChangesToDoS class with all the flags if changes need to be made and the changes to make """ - logger.info(f"TEST LOG {nhs_entity.org_sub_type}") - logger.warning(f"TEST LOG {nhs_entity.org_sub_type}") - # Set up the holder class changes_to_dos = ChangesToDoS(dos_service=dos_service, nhs_entity=nhs_entity, service_histories=service_histories) @@ -83,6 +80,8 @@ def compare_nhs_uk_and_dos_data( # Compare blood pressure changes_to_dos = check_blood_pressure_for_change(changes_to_dos=changes_to_dos) # Compare contraception + logger.warning(f"TEST LOG check for change {nhs_entity.org_sub_type}") + return check_contraception_for_change(changes_to_dos=changes_to_dos) From d28d6de81fa32b8d90548c3089775687bf6d07de Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Tue, 12 Nov 2024 09:20:01 +0000 Subject: [PATCH 16/23] More logging to sync --- application/service_sync/data_processing/check_for_change.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/service_sync/data_processing/check_for_change.py b/application/service_sync/data_processing/check_for_change.py index ff706c31d..6559c2edb 100644 --- a/application/service_sync/data_processing/check_for_change.py +++ b/application/service_sync/data_processing/check_for_change.py @@ -80,7 +80,7 @@ def compare_nhs_uk_and_dos_data( # Compare blood pressure changes_to_dos = check_blood_pressure_for_change(changes_to_dos=changes_to_dos) # Compare contraception - logger.warning(f"TEST LOG check for change {nhs_entity.org_sub_type}") + logger.warning(f"TEST LOG check for change {changes_to_dos.nhs_entity.org_sub_type}") return check_contraception_for_change(changes_to_dos=changes_to_dos) From efed7b8c36238f18fc15cc801a9b48e55e68afe4 Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Tue, 12 Nov 2024 10:23:45 +0000 Subject: [PATCH 17/23] More logging to sync --- application/service_sync/service_sync.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/service_sync/service_sync.py b/application/service_sync/service_sync.py index db0462c11..c8247ffb8 100644 --- a/application/service_sync/service_sync.py +++ b/application/service_sync/service_sync.py @@ -55,15 +55,17 @@ def lambda_handler(event: SQSEvent, context: LambdaContext) -> None: # noqa: AR service_histories=service_histories, ) - logger.info(f"TEST LOG {nhs_entity.org_sub_type}") + logger.warning(f"TEST LOG {changes_to_dos.nhs_entity.org_sub_type}") - logger.warning(f"TEST LOG {changes_to_dos}") + logger.warning(f"TEST LOG22 {changes_to_dos}") # Update Service History with changes to be made service_histories = changes_to_dos.service_histories # Update DoS data update_dos_data(changes_to_dos=changes_to_dos, service_id=int(service_id), service_histories=service_histories) # Delete the message from the queue remove_sqs_message_from_queue(receipt_handle=record.receipt_handle) + logger.warning(f"final log {changes_to_dos}") + # Log custom metrics logger.warning( "Update Request Success TEST", From 91952fe64d234ae90c1928966bd137837bde89f4 Mon Sep 17 00:00:00 2001 From: Thomas Cordall Date: Thu, 14 Nov 2024 14:32:49 +0000 Subject: [PATCH 18/23] Removed test logging --- README.md | 1 - .../change_event_validation.py | 2 -- .../data_processing/check_for_change.py | 22 ------------------- application/service_sync/service_sync.py | 8 +------ 4 files changed, 1 insertion(+), 32 deletions(-) diff --git a/README.md b/README.md index ce557d454..2d3c0e795 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # DoS Integration - ## Table of Contents - [DoS Integration](#dos-integration) diff --git a/application/ingest_change_event/change_event_validation.py b/application/ingest_change_event/change_event_validation.py index 0aec824e2..6e5964e61 100644 --- a/application/ingest_change_event/change_event_validation.py +++ b/application/ingest_change_event/change_event_validation.py @@ -58,8 +58,6 @@ def validate_organisation_keys(org_type_id: str, org_sub_type: str) -> None: ValidationError: Either Org Type ID or Org Sub Type is not part of the valid list """ validate_organisation_type_id(org_type_id) - #logger.info("test log: ", len(PHARMACY_ORGANISATION_SUB_TYPES)) - #logger.info("test log: ", PHARMACY_ORGANISATION_SUB_TYPES) if org_sub_type in PHARMACY_ORGANISATION_SUB_TYPES: logger.info(f"Subtype type id: {org_sub_type} validated") else: diff --git a/application/service_sync/data_processing/check_for_change.py b/application/service_sync/data_processing/check_for_change.py index 6559c2edb..0a08cb1c0 100644 --- a/application/service_sync/data_processing/check_for_change.py +++ b/application/service_sync/data_processing/check_for_change.py @@ -63,7 +63,6 @@ def compare_nhs_uk_and_dos_data( Returns: ChangesToDoS: ChangesToDoS class with all the flags if changes need to be made and the changes to make """ - # Set up the holder class changes_to_dos = ChangesToDoS(dos_service=dos_service, nhs_entity=nhs_entity, service_histories=service_histories) @@ -80,8 +79,6 @@ def compare_nhs_uk_and_dos_data( # Compare blood pressure changes_to_dos = check_blood_pressure_for_change(changes_to_dos=changes_to_dos) # Compare contraception - logger.warning(f"TEST LOG check for change {changes_to_dos.nhs_entity.org_sub_type}") - return check_contraception_for_change(changes_to_dos=changes_to_dos) @@ -415,22 +412,3 @@ def status_id_change(changes_to_dos: ChangesToDoS, new_value: bool, previous_val ), ) return changes_to_dos - -def check_org_for_change(changes_to_dos: ChangesToDoS) -> ChangesToDoS: - """Compares and creates change for website if needed. - - Args: - changes_to_dos (ChangesToDoS): ChangesToDoS holder object - - Returns: - ChangesToDoS: ChangesToDoS holder object - """ - if compare_website(changes=changes_to_dos): - changes_to_dos = services_change( - changes_to_dos=changes_to_dos, - change_key=DOS_WEBSITE_CHANGE_KEY, - new_value=changes_to_dos.new_website, - previous_value=changes_to_dos.current_website, - service_table_field_name="web", - ) - return changes_to_dos diff --git a/application/service_sync/service_sync.py b/application/service_sync/service_sync.py index c8247ffb8..880603ad0 100644 --- a/application/service_sync/service_sync.py +++ b/application/service_sync/service_sync.py @@ -54,21 +54,15 @@ def lambda_handler(event: SQSEvent, context: LambdaContext) -> None: # noqa: AR nhs_entity=nhs_entity, service_histories=service_histories, ) - - logger.warning(f"TEST LOG {changes_to_dos.nhs_entity.org_sub_type}") - - logger.warning(f"TEST LOG22 {changes_to_dos}") # Update Service History with changes to be made service_histories = changes_to_dos.service_histories # Update DoS data update_dos_data(changes_to_dos=changes_to_dos, service_id=int(service_id), service_histories=service_histories) # Delete the message from the queue remove_sqs_message_from_queue(receipt_handle=record.receipt_handle) - logger.warning(f"final log {changes_to_dos}") - # Log custom metrics logger.warning( - "Update Request Success TEST", + "Update Request Success", latency=(time_ns() // 1000000) - int(record.message_attributes.get("message_received", {}).get("stringValue")), environment=getenv("ENVIRONMENT"), From 1a48afb15f86cfb606519fda578fafcf18e4571f Mon Sep 17 00:00:00 2001 From: ManithaSrinivasa Date: Mon, 18 Nov 2024 11:03:31 +0000 Subject: [PATCH 19/23] Adding new test --- .../features/F002_Invalid_Change_Events.feature | 8 ++++++++ 1 file changed, 8 insertions(+) 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 From 217a927b6554683248692a02b99f20b1f1c53911 Mon Sep 17 00:00:00 2001 From: ManithaSrinivasa Date: Mon, 18 Nov 2024 20:19:57 +0000 Subject: [PATCH 20/23] Added test cases --- .../features/F001_Valid_Change_Events.feature | 23 +++++++++++++++++++ test/integration/steps/functions/utils.py | 4 ++-- test/integration/steps/test_steps.py | 15 ++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/test/integration/features/F001_Valid_Change_Events.feature b/test/integration/features/F001_Valid_Change_Events.feature index 004786dff..95796b30e 100644 --- a/test/integration/features/F001_Valid_Change_Events.feature +++ b/test/integration/features/F001_Valid_Change_Events.feature @@ -513,3 +513,26 @@ 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" + 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 "" 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 | diff --git a/test/integration/steps/functions/utils.py b/test/integration/steps/functions/utils.py index d3d15c661..334d015cf 100644 --- a/test/integration/steps/functions/utils.py +++ b/test/integration/steps/functions/utils.py @@ -80,9 +80,9 @@ 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 + changed_data = context.generator_data["web"] case "address": changed_data = get_address_string(context) case "postcode": diff --git a/test/integration/steps/test_steps.py b/test/integration/steps/test_steps.py index c8c4a6566..0dc196eab 100644 --- a/test/integration/steps/test_steps.py +++ b/test/integration/steps/test_steps.py @@ -817,6 +817,21 @@ def change_event_with_blank_opening_times(context: Context) -> 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. From 487b4427412d527dbaaeabcb5e1cb13bf76373a8 Mon Sep 17 00:00:00 2001 From: ManithaSrinivasa Date: Mon, 18 Nov 2024 20:54:52 +0000 Subject: [PATCH 21/23] Added test cases --- test/integration/steps/test_steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/steps/test_steps.py b/test/integration/steps/test_steps.py index 0dc196eab..ca36c76fc 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. From 49919123e6a828b60f682532977f4c79d8221b25 Mon Sep 17 00:00:00 2001 From: ManithaSrinivasa Date: Wed, 20 Nov 2024 13:02:07 +0000 Subject: [PATCH 22/23] 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. From 840b8085582389476f9001432c1ca1075142bf9a Mon Sep 17 00:00:00 2001 From: ManithaSrinivasa Date: Wed, 20 Nov 2024 13:16:36 +0000 Subject: [PATCH 23/23] Removed print statement --- test/integration/features/F001_Valid_Change_Events.feature | 4 ++-- test/integration/features/F006_Opening_Times.feature | 4 ++-- test/integration/steps/test_steps.py | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/integration/features/F001_Valid_Change_Events.feature b/test/integration/features/F001_Valid_Change_Events.feature index baa4ab910..f4db2d5d5 100644 --- a/test/integration/features/F001_Valid_Change_Events.feature +++ b/test/integration/features/F001_Valid_Change_Events.feature @@ -538,8 +538,8 @@ Feature: F001. Ensure valid change events are converted and sent to DoS | 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" + @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" diff --git a/test/integration/features/F006_Opening_Times.feature b/test/integration/features/F006_Opening_Times.feature index 9b5161d52..f592daecc 100644 --- a/test/integration/features/F006_Opening_Times.feature +++ b/test/integration/features/F006_Opening_Times.feature @@ -80,8 +80,8 @@ Feature: F006. Opening times 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" + @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 diff --git a/test/integration/steps/test_steps.py b/test/integration/steps/test_steps.py index 7c3bad065..22e82b410 100644 --- a/test/integration/steps/test_steps.py +++ b/test/integration/steps/test_steps.py @@ -1210,7 +1210,6 @@ def the_dos_service_has_been_updated_with_the_specified_date_is_captured_by_dos( 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)