|
1 | 1 | from datetime import datetime, timedelta |
2 | 2 | import pandas as pd |
3 | 3 | import pytest |
4 | | -from _pytest.fixtures import FixtureRequest |
5 | 4 | import logging |
6 | 5 | from playwright.sync_api import Page |
7 | 6 | from classes.subject import Subject |
|
23 | 22 | from pages.screening_practitioner_appointments.book_appointment_page import ( |
24 | 23 | BookAppointmentPage, |
25 | 24 | ) |
26 | | -from pages.screening_practitioner_appointments.practitioner_availability_page import ( |
27 | | - PractitionerAvailabilityPage, |
28 | | -) |
29 | | -from pages.screening_practitioner_appointments.screening_practitioner_appointments_page import ( |
30 | | - ScreeningPractitionerAppointmentsPage, |
31 | | -) |
32 | | -from pages.screening_practitioner_appointments.set_availability_page import ( |
33 | | - SetAvailabilityPage, |
34 | | -) |
35 | 25 | from pages.screening_subject_search.advance_fobt_screening_episode_page import ( |
36 | 26 | AdvanceFOBTScreeningEpisodePage, |
37 | 27 | ) |
|
44 | 34 | from utils.batch_processing import batch_processing |
45 | 35 | from utils.calendar_picker import CalendarPicker |
46 | 36 | from utils.fit_kit import FitKitGeneration |
47 | | -from utils.last_test_run import has_test_run_today |
48 | 37 | from utils.oracle.oracle import OracleDB |
49 | 38 | from utils.oracle.oracle_specific_functions import ( |
50 | 39 | update_kit_service_management_entity, |
51 | 40 | execute_fit_kit_stored_procedures, |
52 | | - set_org_parameter_value, |
53 | | - check_parameter, |
54 | 41 | ) |
55 | 42 | from utils.oracle.subject_selection_query_builder import SubjectSelectionQueryBuilder |
56 | 43 | from utils.screening_subject_page_searcher import ( |
|
61 | 48 | from utils.datasets.investigation_datasets import go_from_a99_status_to_a259_status |
62 | 49 |
|
63 | 50 |
|
64 | | -@pytest.fixture(scope="function", autouse=True) |
65 | | -def before_each(page: Page, request: FixtureRequest) -> None: |
66 | | - """ |
67 | | - Checks that the required organization parameters are set correctly before each test. |
68 | | - If not, it sets them to the expected values. |
69 | | - Also sets up appointments if the test has not been run today. |
70 | | - """ |
71 | | - param_12_set_correctly = check_parameter(12, "23162", "10") |
72 | | - param_28_set_correctly = check_parameter(28, "23162", "07:00") |
73 | | - param_29_set_correctly = check_parameter(29, "23162", "20:00") |
74 | | - if not param_12_set_correctly: |
75 | | - set_org_parameter_value(12, "10", "23162") |
76 | | - if not param_28_set_correctly: |
77 | | - set_org_parameter_value(28, "07:00", "23162") |
78 | | - if not param_29_set_correctly: |
79 | | - set_org_parameter_value(29, "20:00", "23162") |
80 | | - |
81 | | - base_url = request.config.getoption("--base-url") |
82 | | - if not has_test_run_today( |
83 | | - "subject/episodes/datasets/investigation/endoscopy/polypcategories/test_setup", base_url # type: ignore |
84 | | - ): |
85 | | - setup_appointments(page) |
86 | | - |
87 | | - |
| 51 | +@pytest.mark.usefixtures("setup_org_and_appointments") |
88 | 52 | @pytest.mark.vpn_required |
89 | 53 | def test_setup_subjects_as_a99(page: Page, subjects_to_run_for: int) -> None: |
90 | 54 | """ |
@@ -115,6 +79,7 @@ def test_setup_subjects_as_a99(page: Page, subjects_to_run_for: int) -> None: |
115 | 79 | LogoutPage(page).log_out() |
116 | 80 |
|
117 | 81 |
|
| 82 | +@pytest.mark.usefixtures("setup_org_and_appointments") |
118 | 83 | @pytest.mark.vpn_required |
119 | 84 | def test_setup_subjects_as_a259(page: Page, subjects_to_run_for: int) -> None: |
120 | 85 | """ |
@@ -173,35 +138,6 @@ def test_setup_subjects_as_a259(page: Page, subjects_to_run_for: int) -> None: |
173 | 138 | LogoutPage(page).log_out() |
174 | 139 |
|
175 | 140 |
|
176 | | -def setup_appointments(page: Page) -> None: |
177 | | - """ |
178 | | - Set up appointments for multiple practitioners at a screening centre. |
179 | | - This function logs in as a Screening Centre Manager, sets availability for |
180 | | - practitioners, and creates appointments for the next 10 practitioners. |
181 | | - """ |
182 | | - UserTools.user_login(page, "Screening Centre Manager at BCS001") |
183 | | - for index in range(10): |
184 | | - BasePage(page).go_to_screening_practitioner_appointments_page() |
185 | | - ScreeningPractitionerAppointmentsPage(page).go_to_set_availability_page() |
186 | | - SetAvailabilityPage(page).go_to_practitioner_availability_page() |
187 | | - PractitionerAvailabilityPage(page).select_site_dropdown_option( |
188 | | - "THE ROYAL HOSPITAL (WOLVERHAMPTON)" |
189 | | - ) |
190 | | - PractitionerAvailabilityPage( |
191 | | - page |
192 | | - ).select_practitioner_dropdown_option_from_index(index + 1) |
193 | | - PractitionerAvailabilityPage(page).click_calendar_button() |
194 | | - CalendarPicker(page).select_day(datetime.today()) |
195 | | - PractitionerAvailabilityPage(page).click_show_button() |
196 | | - PractitionerAvailabilityPage(page).enter_start_time("07:00") |
197 | | - PractitionerAvailabilityPage(page).enter_end_time("20:00") |
198 | | - PractitionerAvailabilityPage(page).click_calculate_slots_button() |
199 | | - PractitionerAvailabilityPage(page).enter_number_of_weeks("1") |
200 | | - PractitionerAvailabilityPage(page).click_save_button() |
201 | | - BasePage(page).click_main_menu_link() |
202 | | - LogoutPage(page).log_out() |
203 | | - |
204 | | - |
205 | 141 | def setup_a99_status(page: Page, df: pd.DataFrame) -> pd.DataFrame: |
206 | 142 | """ |
207 | 143 | Set up subjects to have status A99 - Suitable for Endoscopic Test. |
|
0 commit comments