Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/integration/features/F006_Opening_times.feature
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,10 @@ Feature: F006. Opening times
| opening_type |
| General |
| Additional |

@complete @pharmacy_no_log_searches
Scenario: F006S012. Confirm changed different specified opening time for same day is captured in Dos
Given a specified multiple opening time Changed Event is valid
When the Changed Event is sent for processing with "valid" api key
Then the processed Changed Event is replayed with a specified opening time changed
And the Changed Request with changed specified time is captured by Dos
56 changes: 55 additions & 1 deletion test/integration/steps/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from os import getenv
from random import randint
from time import sleep
from dateutil.relativedelta import relativedelta

from faker import Faker
from pytest_bdd import given, scenarios, then, when
Expand Down Expand Up @@ -128,6 +129,31 @@ def a_specified_opening_time_change_event_is_valid(context: Context):
return context


@given("a specified multiple opening time Changed Event is valid", target_fixture="context")
def a_specified_multiple_opening_time_change_event_is_valid(context: Context):
context.change_event = set_opening_times_change_event("pharmacy")
date = dt.today() + relativedelta(months=1)
context.change_event.specified_opening_times.append(
{
"Weekday": "",
"OpeningTime": "",
"ClosingTime": "",
"OffsetOpeningTime": 0,
"OffsetClosingTime": 0,
"OpeningTimeType": "Additional",
"AdditionalOpeningDate": date.strftime("%b %d %Y"),
"IsOpen": False,
}
)
context.change_event.specified_opening_times[-2]["OpeningTime"] = "09:00"
context.change_event.specified_opening_times[-2]["ClosingTime"] = "14:00"
context.change_event.specified_opening_times[-1]["OpeningTime"] = "15:00"
context.change_event.specified_opening_times[-1]["ClosingTime"] = "20:00"
context.change_event.specified_opening_times[-2]["IsOpen"] = True
context.change_event.specified_opening_times[-1]["IsOpen"] = True
return context


@given("an opened standard opening time Changed Event is valid", target_fixture="context")
def a_standard_opening_time_change_event_is_valid(context: Context):
closing_time = datetime.datetime.now().time().strftime("%H:%M")
Expand Down Expand Up @@ -623,7 +649,7 @@ def the_changed_contact_is_not_accepted_by_dos(context: Context, field: str):


@then("the Changed Request with changed specified date and time is captured by Dos")
def the_changed_opening_time_is_accepted_by_dos(context: Context):
def the_changed_opening_date_time_is_accepted_by_dos(context: Context):
"""assert dos API response and validate processed record in Dos CR Queue database"""
open_time = time_to_sec(context.change_event.specified_opening_times[-1]["OpeningTime"])
closing_time = time_to_sec(context.change_event.specified_opening_times[-1]["ClosingTime"])
Expand Down Expand Up @@ -787,6 +813,34 @@ def specified_date_is_removed_from_dos(context: Context):
), f"Error!.. Removed specified date: {removed_date} still exists in Dos"


@then("the processed Changed Event is replayed with a specified opening time changed")
def change_aligned_event_is_replayed(context: Context):
service_id = get_service_id(context.correlation_id)
approver_status = confirm_approver_status(context.correlation_id)
assert approver_status != [], f"Error!.. Dos Change for Serviceid: {service_id} has been REJECTED"
context.change_event.specified_opening_times[-1]["OpeningTime"] = "15:01"
context.change_event.specified_opening_times[-1]["ClosingTime"] = "20:00"
context.correlation_id = f"replayed-{context.correlation_id}"
context.response = process_payload(context.change_event, True, context.correlation_id)
return context


@then("the Changed Request with changed specified time is captured by Dos")
def the_changed_opening_time_is_captured_by_dos(context: Context):
"""assert dos API response and validate processed record in Dos CR Queue database"""
service_id = get_service_id(context.correlation_id)
approver_status = confirm_approver_status(context.correlation_id)
assert approver_status != [], f"Error!.. Dos Change for Serviceid: {service_id} has been REJECTED"
open_time = time_to_sec(context.change_event.specified_opening_times[-1]["OpeningTime"])
closing_time = time_to_sec(context.change_event.specified_opening_times[-1]["ClosingTime"])
changed_time = f"{open_time}-{closing_time}"
cms = "cmsopentimespecified"
assert (
check_specified_received_opening_times_time_in_dos(context.correlation_id, cms, changed_time) is True
), f"ERROR!.. Dos not updated with change: {changed_time}"
return context


@then(parse('the Changed Event is replayed with the pharmacy now "{open_or_closed}"'))
def event_replayed_with_pharmacy_closed(context: Context, open_or_closed):
closing_time = datetime.datetime.now().time().strftime("%H:%M")
Expand Down