Skip to content

Commit 25260b3

Browse files
Addressing SonarQube issues
1 parent 2669e69 commit 25260b3

File tree

4 files changed

+156
-304
lines changed

4 files changed

+156
-304
lines changed

pages/datasets/investigation_dataset_page.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def __init__(self, page: Page):
1616
super().__init__(page)
1717
self.page = page
1818

19+
self.add_intervention_string = "Add Intervention"
20+
1921
# Investigation datasets page locators
2022
self.site_lookup_link = self.page.locator("#UI_SITE_SELECT_LINK")
2123
self.practitioner_link = self.page.locator("#UI_SSP_PIO_SELECT_LINK")
@@ -48,11 +50,11 @@ def __init__(self, page: Page):
4850
self.show_failure_information_details = self.page.locator("#anchorFailure")
4951
self.add_polyp_button = self.page.get_by_role("button", name="Add Polyp")
5052
self.polyp1_add_intervention_button = self.page.get_by_role(
51-
"link", name="Add Intervention"
53+
"link", name=self.add_intervention_string
5254
)
5355
self.polyp2_add_intervention_button = self.page.locator(
5456
"#spanPolypInterventionLink2"
55-
).get_by_role("link", name="Add Intervention")
57+
).get_by_role("link", name=self.add_intervention_string)
5658
self.dataset_complete_checkbox = self.page.locator("#radDatasetCompleteYes")
5759
self.dataset_incomplete_checkbox = self.page.locator("#radDatasetCompleteNo")
5860
self.save_dataset_button = self.page.locator(
@@ -477,7 +479,7 @@ def click_polyp_add_intervention_button(self, polyp_number: int) -> None:
477479

478480
self.click(
479481
self.page.locator(f"#spanPolypInterventionLink{polyp_number}").get_by_role(
480-
"link", name="Add Intervention"
482+
"link", name=self.add_intervention_string
481483
)
482484
)
483485

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

Lines changed: 6 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
from utils.screening_subject_page_searcher import (
6060
search_subject_episode_by_nhs_number,
6161
)
62+
from utils.datasets.investigation_datasets import (
63+
get_subject_with_investigation_dataset_ready,
64+
go_from_investigation_dataset_complete_to_a259_status,
65+
)
6266
from utils.user_tools import UserTools
6367

6468
# Defining dictionaries used in tests
@@ -108,7 +112,7 @@ def before_test(page: Page, request: FixtureRequest) -> None:
108112
"""
109113
if request.node.get_closest_marker("skip_before_test"):
110114
return
111-
df = obtain_test_data()
115+
df = get_subject_with_investigation_dataset_ready()
112116
nhs_no = df.iloc[0]["subject_nhs_number"]
113117
logging.info(f"NHS Number: {nhs_no}")
114118

@@ -1020,88 +1024,7 @@ def test_identify_advanced_colorectal_polyp_from_histology_r(page: Page) -> None
10201024
polyp_histology=polyp_histology,
10211025
)
10221026

1023-
# Enter the test outcome > A315
1024-
BasePage(page).click_back_button()
1025-
BasePage(page).click_back_button()
1026-
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
1027-
AdvanceFOBTScreeningEpisodePage(page).click_enter_diagnostic_test_outcome_button()
1028-
DiagnosticTestOutcomePage(page).select_test_outcome_option(
1029-
OutcomeOfDiagnosticTest.FAILED_TEST_REFER_ANOTHER
1030-
)
1031-
DiagnosticTestOutcomePage(page).click_save_button()
1032-
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
1033-
"A315 - Diagnostic Test Outcome Entered"
1034-
)
1035-
1036-
# Make post investigation contact > A361
1037-
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
1038-
AdvanceFOBTScreeningEpisodePage(page).click_other_post_investigation_button()
1039-
AdvanceFOBTScreeningEpisodePage(page).verify_latest_event_status_value(
1040-
"A361 - Other Post-investigation Contact Required"
1041-
)
1042-
1043-
AdvanceFOBTScreeningEpisodePage(
1044-
page
1045-
).click_record_other_post_investigation_contact_button()
1046-
ContactWithPatientPage(page).select_direction_dropdown_option("To patient")
1047-
ContactWithPatientPage(page).select_caller_id_dropdown_index_option(1)
1048-
ContactWithPatientPage(page).click_calendar_button()
1049-
CalendarPicker(page).v1_calender_picker(datetime.today())
1050-
ContactWithPatientPage(page).enter_start_time("11:00")
1051-
ContactWithPatientPage(page).enter_end_time("12:00")
1052-
ContactWithPatientPage(page).enter_discussion_record_text("Test Automation")
1053-
ContactWithPatientPage(page).select_outcome_dropdown_option(
1054-
"Post-investigation Appointment Not Required"
1055-
)
1056-
ContactWithPatientPage(page).click_save_button()
1057-
BasePage(page).click_back_button()
1058-
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
1059-
"A318 - Post-investigation Appointment NOT Required - Result Letter Created"
1060-
)
1061-
1062-
# Process the A318 letters > A380
1063-
batch_processing(
1064-
page,
1065-
"A318",
1066-
"Result Letters - No Post-investigation Appointment",
1067-
"A380 - Failed Diagnostic Test - Refer Another",
1068-
)
1069-
1070-
# Another contact to bring the subject back to A99
1071-
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
1072-
AdvanceFOBTScreeningEpisodePage(page).click_record_contact_with_patient_button()
1073-
ContactWithPatientPage(page).select_direction_dropdown_option("To patient")
1074-
ContactWithPatientPage(page).select_caller_id_dropdown_index_option(1)
1075-
ContactWithPatientPage(page).click_calendar_button()
1076-
CalendarPicker(page).v1_calender_picker(datetime.today())
1077-
ContactWithPatientPage(page).enter_start_time("11:00")
1078-
ContactWithPatientPage(page).enter_end_time("12:00")
1079-
ContactWithPatientPage(page).enter_discussion_record_text("Test Automation")
1080-
ContactWithPatientPage(page).select_outcome_dropdown_option(
1081-
"Suitable for Endoscopic Test"
1082-
)
1083-
ContactWithPatientPage(page).click_save_button()
1084-
AdvanceFOBTScreeningEpisodePage(page).verify_latest_event_status_value(
1085-
"A99 - Suitable for Endoscopic Test"
1086-
)
1087-
1088-
# Invite for 2nd diagnostic test > A59 - check options
1089-
AdvanceFOBTScreeningEpisodePage(page).click_calendar_button()
1090-
CalendarPicker(page).v1_calender_picker(datetime.today())
1091-
AdvanceFOBTScreeningEpisodePage(page).select_test_type_dropdown_option_2(
1092-
"Colonoscopy"
1093-
)
1094-
AdvanceFOBTScreeningEpisodePage(page).click_invite_for_diagnostic_test_button()
1095-
AdvanceFOBTScreeningEpisodePage(page).click_attend_diagnostic_test_button()
1096-
AttendDiagnosticTestPage(page).select_actual_type_of_test_dropdown_option(
1097-
"Colonoscopy"
1098-
)
1099-
AttendDiagnosticTestPage(page).click_calendar_button()
1100-
CalendarPicker(page).v1_calender_picker(datetime.today())
1101-
AttendDiagnosticTestPage(page).click_save_button()
1102-
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
1103-
"A259 - Attended Diagnostic Test"
1104-
)
1027+
go_from_investigation_dataset_complete_to_a259_status(page)
11051028
SubjectScreeningSummaryPage(page).click_datasets_link()
11061029
SubjectDatasetsPage(page).click_investigation_show_datasets()
11071030

@@ -1163,32 +1086,6 @@ def test_identify_advanced_colorectal_polyp_from_histology_s(page: Page) -> None
11631086
assert_test_results(page, "32")
11641087

11651088

1166-
def obtain_test_data() -> pd.DataFrame:
1167-
"""
1168-
This function builds a query to retrieve subjects based on specific criteria
1169-
and returns a DataFrame containing the results.
1170-
"""
1171-
criteria = {
1172-
"latest episode status": "open",
1173-
"latest episode latest investigation dataset": "colonoscopy_new",
1174-
"latest episode started": "less than 4 years ago",
1175-
}
1176-
user = User()
1177-
subject = Subject()
1178-
1179-
builder = SubjectSelectionQueryBuilder()
1180-
1181-
query, bind_vars = builder.build_subject_selection_query(
1182-
criteria=criteria,
1183-
user=user,
1184-
subject=subject,
1185-
subjects_to_retrieve=1,
1186-
)
1187-
1188-
df = OracleDB().execute_query(query, bind_vars)
1189-
return df
1190-
1191-
11921089
def make_polyp_1_information(**overrides):
11931090
"""
11941091
Create a dictionary containing default information about Polyp 1.

0 commit comments

Comments
 (0)