Skip to content

Commit 382ba6f

Browse files
Addressing some SonarQube issues
1 parent 2cec08c commit 382ba6f

File tree

3 files changed

+15
-34
lines changed

3 files changed

+15
-34
lines changed

pages/datasets/investigation_dataset_page.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def __init__(self, page: Page):
7373
self.edit_dataset_button = self.page.locator(
7474
"#UI_DIV_BUTTON_EDIT1"
7575
).get_by_role("button", name="Edit Dataset")
76+
self.visible_ui_results_string = 'select[id^="UI_RESULTS_"]:visible'
7677

7778
def select_site_lookup_option(self, option: str) -> None:
7879
"""
@@ -96,7 +97,7 @@ def select_site_lookup_option_index(self, option: int) -> None:
9697
option (int): The index of the option to select from the site lookup options.
9798
"""
9899
self.click(self.site_lookup_link)
99-
select_locator = self.page.locator('select[id^="UI_RESULTS_"]:visible')
100+
select_locator = self.page.locator(self.visible_ui_results_string)
100101
select_locator.first.wait_for(state="visible")
101102
# Find all option elements inside the select and click the one at the given index
102103
option_elements = select_locator.first.locator("option")
@@ -125,7 +126,7 @@ def select_practitioner_option_index(self, option: int) -> None:
125126
option (int): The index of the option to select from the practitioner options.
126127
"""
127128
self.click(self.practitioner_link)
128-
select_locator = self.page.locator('select[id^="UI_RESULTS_"]:visible')
129+
select_locator = self.page.locator(self.visible_ui_results_string)
129130
select_locator.first.wait_for(state="visible")
130131
# Find all option elements inside the select and click the one at the given index
131132
option_elements = select_locator.first.locator("option")
@@ -154,7 +155,7 @@ def select_testing_clinician_option_index(self, option: int) -> None:
154155
option (int): The index of the option to select from the testing clinician options.
155156
"""
156157
self.click(self.testing_clinician_link)
157-
select_locator = self.page.locator('select[id^="UI_RESULTS_"]:visible')
158+
select_locator = self.page.locator(self.visible_ui_results_string)
158159
select_locator.first.wait_for(state="visible")
159160
# Find all option elements inside the select and click the one at the given index
160161
option_elements = select_locator.first.locator("option")
@@ -183,7 +184,7 @@ def select_aspirant_endoscopist_option_index(self, option: int) -> None:
183184
option (int): The index of the option to select from the aspirant endoscopist options.
184185
"""
185186
self.click(self.aspirant_endoscopist_link)
186-
select_locator = self.page.locator('select[id^="UI_RESULTS_"]:visible')
187+
select_locator = self.page.locator(self.visible_ui_results_string)
187188
select_locator.first.wait_for(state="visible")
188189
# Find all option elements inside the select and click the one at the given index
189190
option_elements = select_locator.first.locator("option")
@@ -337,7 +338,7 @@ def select_polyp1_pathology_provider_option_index(self, option: int) -> None:
337338
option (int): The index of the option to select from the pathology provider options.
338339
"""
339340
self.click(self.polyp1_pathology_provider)
340-
select_locator = self.page.locator('select[id^="UI_RESULTS_"]:visible')
341+
select_locator = self.page.locator(self.visible_ui_results_string)
341342
select_locator.first.wait_for(state="visible")
342343
# Find all option elements inside the select and click the one at the given index
343344
option_elements = select_locator.first.locator("option")
@@ -353,7 +354,7 @@ def select_polyp1_pathologist_option_index(self, option: int) -> None:
353354
option (int): The index of the option to select from the pathologist options.
354355
"""
355356
self.click(self.polyp1_pathologist)
356-
select_locator = self.page.locator('select[id^="UI_RESULTS_"]:visible')
357+
select_locator = self.page.locator(self.visible_ui_results_string)
357358
select_locator.first.wait_for(state="visible")
358359
# Find all option elements inside the select and click the one at the given index
359360
option_elements = select_locator.first.locator("option")

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,6 @@ def test_identify_advanced_colorectal_polyp_from_histology_d(page: Page) -> None
240240
"""
241241
This test identifies an advanced colorectal polyp from histology results (BCSS-5567 - D).
242242
"""
243-
polyp_1_histology = {
244-
"date of receipt": datetime.today(),
245-
"date of reporting": datetime.today(),
246-
"pathology provider": -1,
247-
"pathologist": -1,
248-
"polyp type": PolypTypeOptions.SERRATED_LESION,
249-
"serrated lesion sub type": SerratedLesionSubTypeOptions.MIXED_POLYP,
250-
"polyp excision complete": PolypExcisionCompleteOptions.R1,
251-
"polyp size": "11",
252-
"polyp dysplasia": PolypDysplasiaOptions.NOT_REPORTED,
253-
"polyp carcinoma": YesNoUncertainOptions.NO,
254-
}
255-
256243
polyp_1_information = make_polyp_1_information(
257244
**{
258245
"location": EndoscopyLocationOptions.SPLENIC_FLEXURE,
@@ -733,7 +720,6 @@ def test_identify_advanced_colorectal_polyp_from_histology_o(page: Page) -> None
733720

734721
polyp_1_histology = make_polyp_1_histology(
735722
**{
736-
"polyp type": PolypTypeOptions.ADENOMA,
737723
"polyp type": PolypTypeOptions.ADENOMA,
738724
"adenoma sub type": AdenomaSubTypeOptions.VILLOUS_ADENOMA,
739725
"polyp size": "3",

utils/investigation_dataset.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ def __init__(self, page: Page):
7878
self.page = page
7979
self.estimate_whole_polyp_size_string = "Estimate of whole polyp size"
8080
self.polyp_access_string = "Polyp Access"
81+
self.failure_reasons_string = "Failure Reasons"
82+
self.excision_technique_string = "Excision Technique"
8183

8284
def complete_with_result(self, nhs_no: str, result: str) -> None:
8385
"""This method fills out the investigation dataset forms based on the test result and the subject's age.
@@ -109,7 +111,7 @@ def complete_with_result(self, nhs_no: str, result: str) -> None:
109111
self.default_investigation_dataset_forms_continuation()
110112
InvestigationDatasetsPage(self.page).click_show_failure_information()
111113
DatasetFieldUtil(self.page).populate_select_locator_for_field_inside_div(
112-
"Failure Reasons",
114+
self.failure_reasons_string,
113115
"divFailureSection",
114116
FailureReasonsOptions.NO_FAILURE_REASONS,
115117
)
@@ -205,7 +207,7 @@ def investigation_datasets_failure_reason(self) -> None:
205207
# Failure Information
206208
InvestigationDatasetsPage(self.page).click_show_failure_information()
207209
DatasetFieldUtil(self.page).populate_select_locator_for_field_inside_div(
208-
"Failure Reasons",
210+
self.failure_reasons_string,
209211
"divFailureSection",
210212
FailureReasonsOptions.BLEEDING_INCIDENT,
211213
)
@@ -262,7 +264,7 @@ def polyps_for_high_risk_result(self) -> None:
262264
"Retrieved", "divPolypTherapy2_1Section", YesNoOptions.NO
263265
)
264266
DatasetFieldUtil(self.page).populate_select_locator_for_field_inside_div(
265-
"Excision Technique",
267+
self.excision_technique_string,
266268
"divPolypTherapy2_1Section",
267269
PolypInterventionExcisionTechniqueOptions.EN_BLOC,
268270
)
@@ -307,7 +309,7 @@ def polyp1_intervention(self) -> None:
307309
"Retrieved", "divPolypTherapy1_1Section", YesNoOptions.NO
308310
)
309311
DatasetFieldUtil(self.page).populate_select_locator_for_field_inside_div(
310-
"Excision Technique",
312+
self.excision_technique_string,
311313
"divPolypTherapy1_1Section",
312314
PolypInterventionExcisionTechniqueOptions.EN_BLOC,
313315
)
@@ -440,8 +442,6 @@ def complete_dataset_with_args(
440442
DatasetFieldUtil(self.page).populate_select_locator_for_field(
441443
"Late outcome", value
442444
)
443-
case _:
444-
pass
445445

446446
# Completion Proof Information
447447
if completion_information:
@@ -455,7 +455,7 @@ def complete_dataset_with_args(
455455
# Failure Information
456456
InvestigationDatasetsPage(self.page).click_show_failure_information()
457457
DatasetFieldUtil(self.page).populate_select_locator_for_field_inside_div(
458-
"Failure Reasons",
458+
self.failure_reasons_string,
459459
"divFailureSection",
460460
failure_information["failure reasons"],
461461
)
@@ -510,8 +510,6 @@ def complete_dataset_with_args(
510510
"divLeftInSitu1",
511511
value,
512512
)
513-
case _:
514-
pass
515513

516514
if polyp_1_intervention:
517515
InvestigationDatasetsPage(
@@ -553,7 +551,7 @@ def complete_dataset_with_args(
553551
DatasetFieldUtil(
554552
self.page
555553
).populate_select_locator_for_field_inside_div(
556-
"Excision Technique",
554+
self.excision_technique_string,
557555
"divPolypTherapy1_1Section",
558556
value,
559557
)
@@ -565,8 +563,6 @@ def complete_dataset_with_args(
565563
"divPolypAppearsFullyResected1_1",
566564
value,
567565
)
568-
case _:
569-
pass
570566

571567
if polyp_1_histology:
572568
for key, value in polyp_1_histology.items():
@@ -651,8 +647,6 @@ def complete_dataset_with_args(
651647
"divTumourFindings1_1",
652648
value,
653649
)
654-
case _:
655-
pass
656650

657651
InvestigationDatasetsPage(self.page).check_dataset_complete_checkbox()
658652
InvestigationDatasetsPage(self.page).click_save_dataset_button()

0 commit comments

Comments
 (0)