Skip to content

Commit fad4824

Browse files
Addressing PR comments
1 parent 1297570 commit fad4824

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

conftest.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,29 +116,34 @@ def subjects_to_run_for(request: FixtureRequest) -> int:
116116

117117

118118
@pytest.fixture(scope="function")
119-
def setup_org_and_appointments(page: Page, request: FixtureRequest) -> None:
119+
def setup_org_and_appointments(
120+
page: Page, request: FixtureRequest, general_properties: dict
121+
) -> None:
120122
"""
121123
Ensures required org parameters and appointments are set up.
122124
Only runs once per day per environment, regardless of which test calls it.
123125
124126
This fixture is designed to be used in tests that require a specific setup of the organisation and appointments.
127+
125128
Example usage:
126-
@pytest.mark.usefixtures("setup_org_and_appointments")
127-
def test_my_function(page: Page):
128-
# Your test code here
129129
130-
def test_my_function(page: Page, setup_org_and_appointments):
131-
# Your test code here
130+
@pytest.mark.usefixtures("setup_org_and_appointments")
131+
def test_my_function(page: Page):
132+
# Your test code here
133+
134+
def test_my_function(page: Page, setup_org_and_appointments):
135+
# Your test code here
132136
"""
133-
param_12_set_correctly = check_parameter(12, "23162", "10")
134-
param_28_set_correctly = check_parameter(28, "23162", "07:00")
135-
param_29_set_correctly = check_parameter(29, "23162", "20:00")
137+
org_id = general_properties["eng_screening_centre_id"]
138+
param_12_set_correctly = check_parameter(12, org_id, "10")
139+
param_28_set_correctly = check_parameter(28, org_id, "07:00")
140+
param_29_set_correctly = check_parameter(29, org_id, "20:00")
136141
if not param_12_set_correctly:
137-
set_org_parameter_value(12, "10", "23162")
142+
set_org_parameter_value(12, "10", org_id)
138143
if not param_28_set_correctly:
139-
set_org_parameter_value(28, "07:00", "23162")
144+
set_org_parameter_value(28, "07:00", org_id)
140145
if not param_29_set_correctly:
141-
set_org_parameter_value(29, "20:00", "23162")
146+
set_org_parameter_value(29, "20:00", org_id)
142147

143148
base_url = request.config.getoption("--base-url")
144149
fixture_name = "setup_org_and_appointments"

utils/appointments.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ def setup_appointments(page: Page, no_of_practitioners: int, max: bool = False)
2929
UserTools.user_login(page, "Screening Centre Manager at BCS001")
3030

3131
if max:
32-
BasePage(page).go_to_screening_practitioner_appointments_page()
33-
ScreeningPractitionerAppointmentsPage(page).go_to_set_availability_page()
34-
SetAvailabilityPage(page).go_to_practitioner_availability_page()
35-
PractitionerAvailabilityPage(page).select_site_dropdown_option(
36-
"THE ROYAL HOSPITAL (WOLVERHAMPTON)"
37-
)
32+
go_to_appointments_page_and_select_site(page)
3833
total_practitioners = (
3934
PractitionerAvailabilityPage(page)
4035
.screening_practitioner_dropdown.locator("option")
@@ -46,12 +41,7 @@ def setup_appointments(page: Page, no_of_practitioners: int, max: bool = False)
4641
logging.info(f"Setting up appointments for {no_of_practitioners} practitioners")
4742
for index in range(no_of_practitioners):
4843
logging.info(f"Setting up appointments for practitioner {index + 1}")
49-
BasePage(page).go_to_screening_practitioner_appointments_page()
50-
ScreeningPractitionerAppointmentsPage(page).go_to_set_availability_page()
51-
SetAvailabilityPage(page).go_to_practitioner_availability_page()
52-
PractitionerAvailabilityPage(page).select_site_dropdown_option(
53-
"THE ROYAL HOSPITAL (WOLVERHAMPTON)"
54-
)
44+
go_to_appointments_page_and_select_site(page)
5545
PractitionerAvailabilityPage(
5646
page
5747
).select_practitioner_dropdown_option_from_index(index + 1)
@@ -66,3 +56,18 @@ def setup_appointments(page: Page, no_of_practitioners: int, max: bool = False)
6656
logging.info(f"Appointments set for practitioner {index + 1} at BCS001")
6757
BasePage(page).click_main_menu_link()
6858
LogoutPage(page).log_out()
59+
60+
61+
def go_to_appointments_page_and_select_site(page: Page) -> None:
62+
"""
63+
Navigate to the Screening Practitioner Appointments page.
64+
65+
Args:
66+
page (Page): The Playwright page object.
67+
"""
68+
BasePage(page).go_to_screening_practitioner_appointments_page()
69+
ScreeningPractitionerAppointmentsPage(page).go_to_set_availability_page()
70+
SetAvailabilityPage(page).go_to_practitioner_availability_page()
71+
PractitionerAvailabilityPage(page).select_site_dropdown_option(
72+
"THE ROYAL HOSPITAL (WOLVERHAMPTON)"
73+
)

0 commit comments

Comments
 (0)