Skip to content

Commit a0120ad

Browse files
Reducing duplicated code even more
1 parent f6c0a94 commit a0120ad

File tree

4 files changed

+47
-109
lines changed

4 files changed

+47
-109
lines changed

tests/regression/subject/episodes/datasets/investigation/endoscopy/polypcategories/test_advanced_colorectal_polyp.py

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,9 @@
3030
)
3131
from pages.datasets.subject_datasets_page import SubjectDatasetsPage
3232
from pages.logout.log_out_page import LogoutPage
33-
from pages.screening_subject_search.attend_diagnostic_test_page import (
34-
AttendDiagnosticTestPage,
35-
)
36-
from pages.screening_subject_search.contact_with_patient_page import (
37-
ContactWithPatientPage,
38-
)
39-
from pages.screening_subject_search.diagnostic_test_outcome_page import (
40-
DiagnosticTestOutcomePage,
41-
OutcomeOfDiagnosticTest,
42-
)
4333
from pages.screening_subject_search.subject_screening_summary_page import (
4434
SubjectScreeningSummaryPage,
4535
)
46-
from pages.screening_subject_search.advance_fobt_screening_episode_page import (
47-
AdvanceFOBTScreeningEpisodePage,
48-
)
49-
from utils.calendar_picker import CalendarPicker
5036
from utils.investigation_dataset import (
5137
InvestigationDatasetCompletion,
5238
)
@@ -57,6 +43,7 @@
5743
get_subject_with_investigation_dataset_ready,
5844
go_from_investigation_dataset_complete_to_a259_status,
5945
get_subject_with_a99_status,
46+
go_from_a99_Status_to_a259_status,
6047
)
6148
from utils.user_tools import UserTools
6249

@@ -929,34 +916,7 @@ def test_identify_advanced_colorectal_polyp_from_histology_r(page: Page) -> None
929916
logging.info(f"NHS Number: {nhs_no}")
930917

931918
UserTools.user_login(page, "Screening Centre Manager at BCS001")
932-
BasePage(page).click_main_menu_link()
933-
BasePage(page).go_to_screening_subject_search_page()
934-
search_subject_episode_by_nhs_number(page, nhs_no)
935-
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
936-
937-
AdvanceFOBTScreeningEpisodePage(page).click_calendar_button()
938-
CalendarPicker(page).v1_calender_picker(datetime.today())
939-
940-
AdvanceFOBTScreeningEpisodePage(page).select_test_type_dropdown_option(
941-
"Colonoscopy"
942-
)
943-
944-
AdvanceFOBTScreeningEpisodePage(page).click_invite_for_diagnostic_test_button()
945-
AdvanceFOBTScreeningEpisodePage(page).verify_latest_event_status_value(
946-
"A59 - Invited for Diagnostic Test"
947-
)
948-
949-
AdvanceFOBTScreeningEpisodePage(page).click_attend_diagnostic_test_button()
950-
951-
AttendDiagnosticTestPage(page).select_actual_type_of_test_dropdown_option(
952-
"Colonoscopy"
953-
)
954-
AttendDiagnosticTestPage(page).click_calendar_button()
955-
CalendarPicker(page).v1_calender_picker(datetime.today())
956-
AttendDiagnosticTestPage(page).click_save_button()
957-
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
958-
"A259 - Attended Diagnostic Test"
959-
)
919+
go_from_a99_Status_to_a259_status(page, nhs_no)
960920

961921
SubjectScreeningSummaryPage(page).click_datasets_link()
962922
SubjectDatasetsPage(page).click_investigation_show_datasets()

tests/regression/subject/episodes/datasets/investigation/endoscopy/polypcategories/test_diminutive_rectal_hyperplastic_polyp.py

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,9 @@
2525
)
2626
from pages.datasets.subject_datasets_page import SubjectDatasetsPage
2727
from pages.logout.log_out_page import LogoutPage
28-
from pages.screening_subject_search.attend_diagnostic_test_page import (
29-
AttendDiagnosticTestPage,
30-
)
3128
from pages.screening_subject_search.subject_screening_summary_page import (
3229
SubjectScreeningSummaryPage,
3330
)
34-
from pages.screening_subject_search.advance_fobt_screening_episode_page import (
35-
AdvanceFOBTScreeningEpisodePage,
36-
)
37-
from utils.calendar_picker import CalendarPicker
3831
from utils.investigation_dataset import (
3932
InvestigationDatasetCompletion,
4033
)
@@ -46,6 +39,7 @@
4639
get_subject_with_investigation_dataset_ready,
4740
go_from_investigation_dataset_complete_to_a259_status,
4841
get_subject_with_a99_status,
42+
go_from_a99_Status_to_a259_status,
4943
)
5044

5145
general_information = {
@@ -276,33 +270,7 @@ def test_identify_diminutive_rectal_hyperplastic_polyp_from_histology_b(
276270

277271
UserTools.user_login(page, "Screening Centre Manager at BCS001")
278272

279-
BasePage(page).go_to_screening_subject_search_page()
280-
search_subject_episode_by_nhs_number(page, nhs_no)
281-
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
282-
283-
AdvanceFOBTScreeningEpisodePage(page).click_calendar_button()
284-
CalendarPicker(page).v1_calender_picker(datetime.today())
285-
286-
AdvanceFOBTScreeningEpisodePage(page).select_test_type_dropdown_option(
287-
"Colonoscopy"
288-
)
289-
290-
AdvanceFOBTScreeningEpisodePage(page).click_invite_for_diagnostic_test_button()
291-
AdvanceFOBTScreeningEpisodePage(page).verify_latest_event_status_value(
292-
"A59 - Invited for Diagnostic Test"
293-
)
294-
295-
AdvanceFOBTScreeningEpisodePage(page).click_attend_diagnostic_test_button()
296-
297-
AttendDiagnosticTestPage(page).select_actual_type_of_test_dropdown_option(
298-
"Colonoscopy"
299-
)
300-
AttendDiagnosticTestPage(page).click_calendar_button()
301-
CalendarPicker(page).v1_calender_picker(datetime.today())
302-
AttendDiagnosticTestPage(page).click_save_button()
303-
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
304-
"A259 - Attended Diagnostic Test"
305-
)
273+
go_from_a99_Status_to_a259_status(page, nhs_no)
306274

307275
SubjectScreeningSummaryPage(page).click_datasets_link()
308276
SubjectDatasetsPage(page).click_investigation_show_datasets()

tests/regression/subject/episodes/datasets/investigation/endoscopy/polypcategories/test_setup.py

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
from pages.screening_subject_search.advance_fobt_screening_episode_page import (
3636
AdvanceFOBTScreeningEpisodePage,
3737
)
38-
from pages.screening_subject_search.attend_diagnostic_test_page import (
39-
AttendDiagnosticTestPage,
40-
)
4138
from pages.screening_subject_search.episode_events_and_notes_page import (
4239
EpisodeEventsAndNotesPage,
4340
)
@@ -61,6 +58,7 @@
6158
verify_subject_event_status_by_nhs_no,
6259
)
6360
from utils.user_tools import UserTools
61+
from utils.datasets.investigation_datasets import go_from_a99_Status_to_a259_status
6462

6563

6664
@pytest.fixture(scope="function", autouse=True)
@@ -169,36 +167,8 @@ def test_setup_subjects_as_a259(page: Page, subjects_to_run_for: int) -> None:
169167

170168
for _, row in df.iterrows():
171169
nhs_no = row["nhs_number"]
172-
173-
verify_subject_event_status_by_nhs_no(
174-
page, nhs_no, "A99 - Suitable for Endoscopic Test"
175-
)
176-
177-
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
178-
179-
AdvanceFOBTScreeningEpisodePage(page).click_calendar_button()
180-
CalendarPicker(page).v1_calender_picker(datetime.today())
181-
182-
AdvanceFOBTScreeningEpisodePage(page).select_test_type_dropdown_option(
183-
"Colonoscopy"
184-
)
185-
186-
AdvanceFOBTScreeningEpisodePage(page).click_invite_for_diagnostic_test_button()
187-
AdvanceFOBTScreeningEpisodePage(page).verify_latest_event_status_value(
188-
"A59 - Invited for Diagnostic Test"
189-
)
190-
191-
AdvanceFOBTScreeningEpisodePage(page).click_attend_diagnostic_test_button()
192-
193-
AttendDiagnosticTestPage(page).select_actual_type_of_test_dropdown_option(
194-
"Colonoscopy"
195-
)
196-
AttendDiagnosticTestPage(page).click_calendar_button()
197-
CalendarPicker(page).v1_calender_picker(datetime.today())
198-
AttendDiagnosticTestPage(page).click_save_button()
199-
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
200-
"A259 - Attended Diagnostic Test"
201-
)
170+
BasePage(page).click_main_menu_link()
171+
go_from_a99_Status_to_a259_status(page, nhs_no)
202172

203173
LogoutPage(page).log_out()
204174

utils/datasets/investigation_datasets.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
from utils.calendar_picker import CalendarPicker
2525
from utils.oracle.oracle import OracleDB
2626
from utils.oracle.subject_selection_query_builder import SubjectSelectionQueryBuilder
27+
from utils.screening_subject_page_searcher import (
28+
search_subject_episode_by_nhs_number,
29+
)
2730

2831

2932
def get_subject_with_investigation_dataset_ready() -> pd.DataFrame:
@@ -78,6 +81,43 @@ def get_subject_with_a99_status() -> pd.DataFrame:
7881
return df
7982

8083

84+
def go_from_a99_Status_to_a259_status(page: Page, nhs_no: str) -> None:
85+
"""
86+
Takes a subject who has the latest episode status A99 - Suitable for Endoscopic Test
87+
and takes them to A259 - Attended Diagnostic Test.
88+
89+
Args:
90+
nhs_no (str): The NHS number of the subject.
91+
"""
92+
BasePage(page).go_to_screening_subject_search_page()
93+
search_subject_episode_by_nhs_number(page, nhs_no)
94+
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
95+
96+
AdvanceFOBTScreeningEpisodePage(page).click_calendar_button()
97+
CalendarPicker(page).v1_calender_picker(datetime.today())
98+
99+
AdvanceFOBTScreeningEpisodePage(page).select_test_type_dropdown_option(
100+
"Colonoscopy"
101+
)
102+
103+
AdvanceFOBTScreeningEpisodePage(page).click_invite_for_diagnostic_test_button()
104+
AdvanceFOBTScreeningEpisodePage(page).verify_latest_event_status_value(
105+
"A59 - Invited for Diagnostic Test"
106+
)
107+
108+
AdvanceFOBTScreeningEpisodePage(page).click_attend_diagnostic_test_button()
109+
110+
AttendDiagnosticTestPage(page).select_actual_type_of_test_dropdown_option(
111+
"Colonoscopy"
112+
)
113+
AttendDiagnosticTestPage(page).click_calendar_button()
114+
CalendarPicker(page).v1_calender_picker(datetime.today())
115+
AttendDiagnosticTestPage(page).click_save_button()
116+
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
117+
"A259 - Attended Diagnostic Test"
118+
)
119+
120+
81121
def go_from_investigation_dataset_complete_to_a259_status(page: Page) -> None:
82122
"""
83123
Takes a subject who has just had thier investigation dataset compelted to having the event status A259 - Attended Diagnostic Test.

0 commit comments

Comments
 (0)