Skip to content

Commit 4e917df

Browse files
Moving some duplicate locators into a seperate function to avoid sonarqube duplication errors
1 parent 8c68faa commit 4e917df

File tree

1 file changed

+33
-106
lines changed

1 file changed

+33
-106
lines changed

tests/smokescreen/test_compartment_6.py

Lines changed: 33 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,8 @@
1111
from pages.datasets.subject_datasets_page import SubjectDatasetsPage
1212

1313

14-
@pytest.mark.vpn_required
15-
@pytest.mark.smokescreen
16-
@pytest.mark.compartment5
17-
def test_compartment_5(page: Page, smokescreen_properties: dict) -> None:
18-
"""
19-
This is the main compartment 6 method
20-
Filling out the investigation datasets for different subjects to get different results for a diagnostic test.
21-
Printing the diagnostic test result letters.
22-
"""
23-
24-
# For the following tests old refers to if they are over 75 at recall
25-
# The recall period is 2 years from the last diagnostic test for a Normal or Abnormal diagnostic test result
26-
# or 3 years for someone who is going in to Surveillance (High-risk findings or LNPCP)
27-
28-
UserTools.user_login(page, "Screening Centre Manager at BCS001")
29-
30-
# This needs to be repeated for two subjects, one old and one not - High Risk Result
31-
nhs_no = "9619187075" # Dummy NHS Number (will not work)
32-
verify_subject_event_status_by_nhs_no(
33-
page, nhs_no, "A323 - Post-investigation Appointment NOT Required"
34-
)
35-
36-
SubjectScreeningSummaryPage(page).click_datasets_link()
37-
SubjectDatasetsPage(page).click_investigation_show_datasets()
38-
39-
# The following code is on the investigation datasets page
14+
# This should go into a util. Adding it here to avoid SonarQube duplication errors:
15+
def investigation_dataset_forms(page: Page) -> None:
4016
page.locator("#UI_SITE_SELECT_LINK").click()
4117
page.locator("#UI_RESULTS_rljsjnkh").select_option("35317")
4218
page.locator("#UI_SSP_PIO_SELECT_LINK").click()
@@ -76,6 +52,35 @@ def test_compartment_5(page: Page, smokescreen_properties: dict) -> None:
7652
)
7753
page.locator("#anchorCompletionProof").click()
7854
page.get_by_label("Proof Parameters").select_option("200575")
55+
56+
57+
@pytest.mark.vpn_required
58+
@pytest.mark.smokescreen
59+
@pytest.mark.compartment5
60+
def test_compartment_5(page: Page, smokescreen_properties: dict) -> None:
61+
"""
62+
This is the main compartment 6 method
63+
Filling out the investigation datasets for different subjects to get different results for a diagnostic test.
64+
Printing the diagnostic test result letters.
65+
"""
66+
67+
# For the following tests old refers to if they are over 75 at recall
68+
# The recall period is 2 years from the last diagnostic test for a Normal or Abnormal diagnostic test result
69+
# or 3 years for someone who is going in to Surveillance (High-risk findings or LNPCP)
70+
71+
UserTools.user_login(page, "Screening Centre Manager at BCS001")
72+
73+
# This needs to be repeated for two subjects, one old and one not - High Risk Result
74+
nhs_no = "9619187075" # Dummy NHS Number (will not work)
75+
verify_subject_event_status_by_nhs_no(
76+
page, nhs_no, "A323 - Post-investigation Appointment NOT Required"
77+
)
78+
79+
SubjectScreeningSummaryPage(page).click_datasets_link()
80+
SubjectDatasetsPage(page).click_investigation_show_datasets()
81+
82+
# The following code is on the investigation datasets page
83+
investigation_dataset_forms(page)
7984
page.locator("#anchorFailure").click()
8085
page.get_by_label("Failure Reasons").select_option("205148")
8186
page.get_by_role("button", name="Add Polyp").click()
@@ -180,45 +185,7 @@ def test_compartment_5(page: Page, smokescreen_properties: dict) -> None:
180185
SubjectDatasetsPage(page).click_investigation_show_datasets()
181186

182187
# The following code is on the investigation datasets page
183-
page.locator("#UI_SITE_SELECT_LINK").click()
184-
page.locator("#UI_RESULTS_cwfoncwk").select_option("35317")
185-
page.locator("#UI_SSP_PIO_SELECT_LINK").click()
186-
page.locator("#UI_RESULTS_hpbvheab").select_option("1251")
187-
page.locator("#UI_CONSULTANT_PIO_SELECT_LINK").click()
188-
page.locator("#UI_RESULTS_ohrfhcdm").select_option("886")
189-
page.locator("#UI_ASPIRANT_ENDOSCOPIST_PIO_SELECT_LINK").click()
190-
page.locator("#anchorDrug").click()
191-
page.locator("#UI_BOWEL_PREP_DRUG1").select_option("200537~Tablet(s)")
192-
page.locator("#UI_BOWEL_PREP_DRUG_DOSE1").click()
193-
page.locator("#UI_BOWEL_PREP_DRUG_DOSE1").fill("10")
194-
page.get_by_role("link", name="Show details").click()
195-
page.locator("#radScopeInsertedYes").check()
196-
page.get_by_role("radio", name="Therapeutic").check()
197-
page.get_by_label("Bowel preparation quality").select_option("17016")
198-
page.get_by_label("Comfort during examination").select_option("18505")
199-
page.get_by_label("Comfort during recovery").select_option("18505")
200-
page.get_by_label("Endoscopist defined extent").select_option(
201-
"17240~Colonoscopy Complete"
202-
)
203-
page.get_by_label("Scope imager used").select_option("17058")
204-
page.get_by_label("Retroverted view").select_option("17059")
205-
page.get_by_role("textbox", name="Start of intubation time").click()
206-
page.get_by_role("textbox", name="Start of intubation time").fill("09:00")
207-
page.get_by_role("textbox", name="Start of extubation time").click()
208-
page.get_by_role("textbox", name="Start of extubation time").fill("09:15")
209-
page.get_by_role("textbox", name="End time of procedure").click()
210-
page.get_by_role("textbox", name="End time of procedure").fill("09:30")
211-
page.get_by_role("textbox", name="Scope ID").click()
212-
page.get_by_role("textbox", name="Scope ID").fill("A1")
213-
page.get_by_label("Insufflation").select_option("200547")
214-
page.get_by_label("Outcome at time of procedure").select_option(
215-
"17148~Complications are optional"
216-
)
217-
page.get_by_label("Late outcome").select_option(
218-
"17216~Complications are not required"
219-
)
220-
page.locator("#anchorCompletionProof").click()
221-
page.get_by_label("Proof Parameters").select_option("200575")
188+
investigation_dataset_forms(page)
222189
page.locator("#anchorFailure").click()
223190
page.get_by_label("Failure Reasons").select_option("205148")
224191
page.get_by_role("button", name="Add Polyp").click()
@@ -311,47 +278,7 @@ def test_compartment_5(page: Page, smokescreen_properties: dict) -> None:
311278
SubjectDatasetsPage(page).click_investigation_show_datasets()
312279

313280
# The following code is on the investigation datasets page
314-
page.locator("#UI_SITE_SELECT_LINK").click()
315-
page.locator("#UI_RESULTS_mjbnjlos").select_option("35317")
316-
page.locator("#UI_SSP_PIO_SELECT_LINK").click()
317-
page.locator("#UI_RESULTS_rquytpri").select_option("1251")
318-
page.locator("#UI_SSP_PIO_SELECT_LINK").click()
319-
page.locator("#UI_RESULTS_rquytpri").select_option("1251")
320-
page.locator("#UI_CONSULTANT_PIO_SELECT_LINK").click()
321-
page.locator("#UI_RESULTS_mkbtktgp").select_option("886")
322-
page.locator("#UI_ASPIRANT_ENDOSCOPIST_PIO_SELECT_LINK").click()
323-
page.locator("#anchorDrug").click()
324-
page.locator("#UI_BOWEL_PREP_DRUG1").select_option("200537~Tablet(s)")
325-
page.locator("#UI_BOWEL_PREP_DRUG_DOSE1").click()
326-
page.locator("#UI_BOWEL_PREP_DRUG_DOSE1").fill("10")
327-
page.get_by_role("link", name="Show details").click()
328-
page.locator("#radScopeInsertedYes").check()
329-
page.get_by_role("radio", name="Diagnostic").check()
330-
page.get_by_label("Bowel preparation quality").select_option("17016")
331-
page.get_by_label("Comfort during examination").select_option("18505")
332-
page.get_by_label("Comfort during recovery").select_option("18505")
333-
page.get_by_label("Endoscopist defined extent").select_option(
334-
"17240~Colonoscopy Complete"
335-
)
336-
page.get_by_label("Scope imager used").select_option("17058")
337-
page.get_by_label("Retroverted view").select_option("17059")
338-
page.get_by_role("textbox", name="Start of intubation time").click()
339-
page.get_by_role("textbox", name="Start of intubation time").fill("09:00")
340-
page.get_by_role("textbox", name="Start of extubation time").click()
341-
page.get_by_role("textbox", name="Start of extubation time").fill("09:15")
342-
page.get_by_role("textbox", name="End time of procedure").click()
343-
page.get_by_role("textbox", name="End time of procedure").fill("09:30")
344-
page.get_by_role("textbox", name="Scope ID").click()
345-
page.get_by_role("textbox", name="Scope ID").fill("A1")
346-
page.get_by_label("Insufflation").select_option("200547")
347-
page.get_by_label("Outcome at time of procedure").select_option(
348-
"17148~Complications are optional"
349-
)
350-
page.get_by_label("Late outcome").select_option(
351-
"17216~Complications are not required"
352-
)
353-
page.locator("#anchorCompletionProof").click()
354-
page.get_by_label("Proof Parameters").select_option("200575")
281+
investigation_dataset_forms(page)
355282
page.locator("#anchorFailure").click()
356283
page.get_by_label("Failure Reasons").select_option("18500")
357284
page.locator("#radDatasetCompleteYes").check()

0 commit comments

Comments
 (0)