Skip to content

Commit fcd51a4

Browse files
committed
Added/Updated docstrings
1 parent 70e6f63 commit fcd51a4

File tree

2 files changed

+51
-34
lines changed

2 files changed

+51
-34
lines changed

tests/smokescreen/test_compartment_6.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
@pytest.mark.vpn_required
1616
@pytest.mark.smokescreen
1717
@pytest.mark.compartment6
18-
def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
18+
def test_compartment_6(page: Page) -> None:
1919
"""
2020
This is the main compartment 6 method
21-
Filling out the investigation datasets for different subjects to get different results for a diagnostic test.
22-
Printing the diagnostic test result letters.
21+
This test fills out the investigation datasets for different subjects to get different outcomes for a diagnostic test
22+
based on the test results and the subject's age, then prints the diagnostic test result letters.
23+
If the subject is old enough and they get a high-risk or LNPCP result, then they are handed over
24+
into symptomatic care, and the relevant letters are printed.
2325
"""
2426

25-
# For the following tests old refers to if they are over 75 at recall
27+
# For the following tests 'old' refers to if a subject is over 75 at recall
2628
# The recall period is 2 years from the last diagnostic test for a Normal or Abnormal diagnostic test result
2729
# or 3 years for someone who is going in to Surveillance (High-risk findings or LNPCP)
2830

@@ -31,7 +33,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
3133
# This needs to be repeated for two subjects, one old and one not - High Risk Result
3234
# Older patient
3335
logging.info("High-risk result for an older subject")
34-
nhs_no = "9104989449"
36+
nhs_no = "9687319364"
3537
InvestigationDatasetCompletion(page).complete_with_result(
3638
nhs_no, InvestigationDatasetResults.HIGH_RISK
3739
)
@@ -41,7 +43,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
4143

4244
# Younger patient
4345
logging.info("High-risk result for a younger subject")
44-
nhs_no = "9160670894"
46+
nhs_no = "9462733759"
4547
InvestigationDatasetCompletion(page).complete_with_result(
4648
nhs_no, InvestigationDatasetResults.HIGH_RISK
4749
)
@@ -52,7 +54,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
5254
# This needs to be repeated for two subjects, one old and one not - LNPCP Result
5355
# Older patient
5456
logging.info("LNPCP result for an older subject")
55-
nhs_no = "9661266328"
57+
nhs_no = "9434999847"
5658
InvestigationDatasetCompletion(page).complete_with_result(
5759
nhs_no, InvestigationDatasetResults.LNPCP
5860
)
@@ -62,7 +64,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
6264

6365
# Younger patient
6466
logging.info("LNPCP result for a younger subject")
65-
nhs_no = "9345483594"
67+
nhs_no = "9773554414"
6668
InvestigationDatasetCompletion(page).complete_with_result(
6769
nhs_no, InvestigationDatasetResults.LNPCP
6870
)
@@ -72,7 +74,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
7274

7375
# This needs to be repeated for 1 subject, age does not matter - Normal Result
7476
logging.info("Normal result for any age subject")
75-
nhs_no_normal = "9029243430"
77+
nhs_no_normal = "9039985766"
7678
InvestigationDatasetCompletion(page).complete_with_result(
7779
nhs_no_normal, InvestigationDatasetResults.NORMAL
7880
)

utils/investigation_dataset.py

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,3 @@
1-
# Create a new util that can populate the investigations dataset to get the following
2-
# results:
3-
4-
# High risk
5-
# LNPCP
6-
# Normal
7-
8-
# This needs to be done as there is a lot of repeat code between the three results
9-
# and we need 2 subjects with high risk and LNPCP results.
10-
# Also create any utils to reduce the amount of duplicated code
11-
# to as close to 0% as possible.
12-
13-
# Update compartment 6
14-
15-
# Add utility guide
16-
17-
# In the code I have added these comments to show the different actions:
18-
# This needs to be repeated for 1 subject, age does not matter - Normal Result
19-
# This needs to be repeated for two subjects, one old and one not - LNPCP Result
20-
# This needs to be repeated for two subjects, one old and one not - High Risk Result
21-
221
from playwright.sync_api import Page
232
from enum import StrEnum
243
import logging
@@ -80,12 +59,22 @@ class InvestigationDatasetResults(StrEnum):
8059

8160

8261
class InvestigationDatasetCompletion:
62+
"""
63+
This class is used to complete the investigation dataset forms for a subject.
64+
It contains methods to fill out the forms based on the result of the investigation dataset.
65+
"""
66+
8367
def __init__(self, page: Page):
8468
self.page = page
8569
self.estimate_whole_polyp_size_string = "Estimate of whole polyp size"
8670
self.polyp_access_string = "Polyp Access"
8771

8872
def complete_with_result(self, nhs_no: str, result: str):
73+
"""This method fills out the investigation dataset forms based on the test result and the subject's age.
74+
Args:
75+
nhs_no (str): The NHS number of the subject.
76+
result (str): The result of the investigation dataset.
77+
"""
8978
if result == InvestigationDatasetResults.HIGH_RISK:
9079
self.go_to_investigation_datasets_page(nhs_no)
9180
self.default_investigation_dataset_forms()
@@ -118,6 +107,10 @@ def complete_with_result(self, nhs_no: str, result: str):
118107
logging.error("Incorrect result entered")
119108

120109
def go_to_investigation_datasets_page(self, nhs_no) -> None:
110+
"""This method navigates to the investigation datasets page for a subject.
111+
Args:
112+
nhs_no (str): The NHS number of the subject.
113+
"""
121114
verify_subject_event_status_by_nhs_no(
122115
self.page, nhs_no, "A323 - Post-investigation Appointment NOT Required"
123116
)
@@ -126,6 +119,7 @@ def go_to_investigation_datasets_page(self, nhs_no) -> None:
126119
SubjectDatasetsPage(self.page).click_investigation_show_datasets()
127120

128121
def default_investigation_dataset_forms(self) -> None:
122+
"""This method fills out the first art of the default investigation dataset form."""
129123
# Investigation Dataset
130124
InvestigationDatasetsPage(self.page).select_site_lookup_option(
131125
SiteLookupOptions.RL401
@@ -145,11 +139,12 @@ def default_investigation_dataset_forms(self) -> None:
145139
DrugTypeOptions.BISACODYL
146140
)
147141
InvestigationDatasetsPage(self.page).fill_drug_type_dose1("10")
148-
# Ensocopy Information
142+
# Endoscopy Information
149143
InvestigationDatasetsPage(self.page).click_show_endoscopy_information()
150144
InvestigationDatasetsPage(self.page).check_endoscope_inserted_yes()
151145

152146
def default_investigation_dataset_forms_continuation(self) -> None:
147+
"""This method fills out the second part of the default investigation dataset form."""
153148
DatasetFieldUtil(self.page).populate_select_locator_for_field(
154149
"Bowel preparation quality", BowelPreparationQualityOptions.GOOD
155150
)
@@ -195,6 +190,7 @@ def default_investigation_dataset_forms_continuation(self) -> None:
195190
)
196191

197192
def investigation_datasets_failure_reason(self) -> None:
193+
"""This method fills out the failure reason section of the investigation dataset form."""
198194
# Failure Information
199195
InvestigationDatasetsPage(self.page).click_show_failure_information()
200196
DatasetFieldUtil(self.page).populate_select_locator_for_field_inside_div(
@@ -204,6 +200,7 @@ def investigation_datasets_failure_reason(self) -> None:
204200
)
205201

206202
def polyps_for_high_risk_result(self) -> None:
203+
"""This method fills out the polyp information section of the investigation dataset form o trigger a high risk result."""
207204
# Polyp Information
208205
InvestigationDatasetsPage(self.page).click_add_polyp_button()
209206
DatasetFieldUtil(self.page).populate_select_locator_for_field_inside_div(
@@ -260,6 +257,7 @@ def polyps_for_high_risk_result(self) -> None:
260257
)
261258

262259
def polyps_for_lnpcp_result(self) -> None:
260+
"""This method fills out the polyp information section of the investigation dataset form to trigger a LNPCP result."""
263261
# Polyp Information
264262
InvestigationDatasetsPage(self.page).click_add_polyp_button()
265263
DatasetFieldUtil(self.page).populate_select_locator_for_field_inside_div(
@@ -279,6 +277,7 @@ def polyps_for_lnpcp_result(self) -> None:
279277
self.polyp1_intervention()
280278

281279
def polyp1_intervention(self) -> None:
280+
"""This method fills out the intervention section of the investigation dataset form for polyp 1."""
282281
InvestigationDatasetsPage(self.page).click_polyp1_add_intervention_button()
283282
DatasetFieldUtil(self.page).populate_select_locator_for_field_inside_div(
284283
"Modality",
@@ -303,18 +302,29 @@ def polyp1_intervention(self) -> None:
303302
)
304303

305304
def save_investigation_dataset(self) -> None:
305+
"""This method saves the investigation dataset form."""
306306
InvestigationDatasetsPage(self.page).check_dataset_complete_checkbox()
307307
InvestigationDatasetsPage(self.page).click_save_dataset_button()
308308

309309

310310
class AfterInvestigationDatasetComplete:
311+
"""
312+
This class is used to progress the episode based on the result of the investigation dataset.
313+
It contains methods to handle the different outcomes of the investigation dataset.
314+
"""
315+
311316
def __init__(self, page: Page) -> None:
312317
self.page = page
313318
self.a318_latest_event_status_string = (
314319
"A318 - Post-investigation Appointment NOT Required - Result Letter Created"
315320
)
316321

317-
def progress_episode_based_on_result(self, result: str, younger: bool):
322+
def progress_episode_based_on_result(self, result: str, younger: bool) -> None:
323+
"""This method progresses the episode based on the result of the investigation dataset.
324+
Args:
325+
result (str): The result of the investigation dataset.
326+
younger (bool): True if the subject is younger than 50, False otherwise.
327+
"""
318328
if result == InvestigationDatasetResults.HIGH_RISK:
319329
self.after_high_risk_result()
320330
if younger:
@@ -334,6 +344,7 @@ def progress_episode_based_on_result(self, result: str, younger: bool):
334344
logging.error("Incorrect result entered")
335345

336346
def after_high_risk_result(self) -> None:
347+
"""This method advances an episode that has a high-risk result."""
337348
InvestigationDatasetsPage(self.page).expect_text_to_be_visible(
338349
"High-risk findings"
339350
)
@@ -361,6 +372,7 @@ def after_high_risk_result(self) -> None:
361372
DiagnosticTestOutcomePage(self.page).click_save_button()
362373

363374
def after_lnpcp_result(self) -> None:
375+
"""This method advances an episode that has a LNPCP result."""
364376
InvestigationDatasetsPage(self.page).expect_text_to_be_visible("LNPCP")
365377
BasePage(self.page).click_back_button()
366378

@@ -384,7 +396,8 @@ def after_lnpcp_result(self) -> None:
384396
)
385397
DiagnosticTestOutcomePage(self.page).click_save_button()
386398

387-
def after_normal_result(self):
399+
def after_normal_result(self) -> None:
400+
"""This method advances an episode that has a normal result."""
388401
InvestigationDatasetsPage(self.page).expect_text_to_be_visible(
389402
"Normal (No Abnormalities"
390403
)
@@ -417,6 +430,7 @@ def after_normal_result(self):
417430
)
418431

419432
def handover_subject_to_symptomatic_care(self) -> None:
433+
"""This method hands over a subject to symptomatic care."""
420434
SubjectScreeningSummaryPage(self.page).verify_latest_event_status_value(
421435
"A394 - Handover into Symptomatic Care for Surveillance - Patient Age"
422436
)
@@ -444,7 +458,8 @@ def handover_subject_to_symptomatic_care(self) -> None:
444458
"A385 - Handover into Symptomatic Care"
445459
)
446460

447-
def record_diagnosis_date(self):
461+
def record_diagnosis_date(self) -> None:
462+
"""This method records the diagnosis date for a subject."""
448463
SubjectScreeningSummaryPage(self.page).verify_latest_event_status_value(
449464
self.a318_latest_event_status_string
450465
)

0 commit comments

Comments
 (0)