Skip to content

Commit

Permalink
Added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ManithaSrinivasa committed Nov 20, 2024
1 parent 487b442 commit 4991912
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 8 deletions.
35 changes: 30 additions & 5 deletions test/integration/features/F001_Valid_Change_Events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<field>" is set to "<value>"
When the Changed Event is sent for processing with "valid" api key
Then the Changed Event is stored in dynamo db
Then the "<DOS_field>" is updated within the DoS DB
And the service history is updated with the "<field>"
And the service history shows "<service_hist_field>" 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"

8 changes: 8 additions & 0 deletions test/integration/features/F005_Support_Functions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions test/integration/features/F006_Opening_Times.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions test/integration/steps/functions/dos/get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/steps/functions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
36 changes: 36 additions & 0 deletions test/integration/steps/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4991912

Please sign in to comment.