Skip to content

Commit 0716a55

Browse files
Adding functionality onto batch processing to pass a list for the latest_event_status
1 parent 9439b8f commit 0716a55

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

docs/utility-guides/BatchProcessing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ This will call the other two functions in order to successfully process a batch.
4343
- Type: `str`
4444
- This is the description of the batch. For example: **Pre-invitation (FIT)** or **Post-investigation Appointment NOT Required**
4545
- `latest_event_status`:
46-
- Type: `str`
47-
- This is the status the subject will get updated to after the batch has been processed. It is used to check that the subject has been updated to the correct status after a batch has been printed
46+
- Type: `str | None`
47+
- This is the status the subject will get updated to after the batch has been processed. It is used to check that the subject has been updated to the correct status after a batch has been printed. If there are multiple idfferent status in the same batch, provide them all in a list.
4848

4949
#### Optional Arguments
5050

pages/screening_subject_search/subject_screening_summary_page.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,34 @@ def verify_latest_event_status_header(self) -> None:
8484
"""Verify that the latest event status header is visible."""
8585
expect(self.latest_event_status).to_be_visible()
8686

87-
def verify_latest_event_status_value(self, latest_event_status: str) -> None:
87+
def verify_latest_event_status_value(self, latest_event_status: str | list) -> None:
8888
"""Verify that the latest event status value is visible."""
89-
logging.info(f"Verifying subject has the status: {latest_event_status}")
90-
latest_event_status_cell = self.get_latest_event_status_cell(
91-
latest_event_status
92-
)
89+
latest_event_status_locator = self.get_first_visible_status(latest_event_status)
90+
status = latest_event_status_locator.inner_text()
91+
logging.info(f"Verifying subject has the status: {status}")
9392
try:
94-
expect(latest_event_status_cell).to_be_visible()
95-
logging.info(f"Subject has the status: {latest_event_status}")
93+
expect(latest_event_status_locator).to_be_visible()
94+
logging.info(f"Subject has the status: {status}")
9695
except Exception:
97-
pytest.fail(f"Subject does not have the status: {latest_event_status}")
96+
pytest.fail(f"Subject does not have the status: {status}")
97+
98+
def get_first_visible_status(self, latest_event_status) -> Locator:
99+
"""
100+
Get the first visible status from the latest event status string or list.
101+
102+
Args:
103+
latest_event_status (str | list): The latest event status to check.
104+
105+
Returns:
106+
Locator: The locator for the first visible status.
107+
"""
108+
if isinstance(latest_event_status, str):
109+
latest_event_status = [latest_event_status]
110+
for status in latest_event_status:
111+
locator = self.page.get_by_role("cell", name=status, exact=True)
112+
if locator.is_visible():
113+
return locator
114+
logging.error("Unable to find any of the listed statuses")
98115

99116
def click_subjects_events_notes(self) -> None:
100117
"""Click on the 'Subject Events & Notes' link."""

utils/batch_processing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def batch_processing(
2424
page: Page,
2525
batch_type: str,
2626
batch_description: str,
27-
latest_event_status: str,
27+
latest_event_status: str | list,
2828
run_timed_events: bool = False,
2929
get_subjects_from_pdf: bool = False,
3030
) -> None:
@@ -35,7 +35,7 @@ def batch_processing(
3535
page (Page): This is the playwright page object
3636
batch_type (str): The event code of the batch. E.g. S1 or S9
3737
batch_description (str): The description of the batch. E.g. Pre-invitation (FIT)
38-
latest_event_status (str): The status the subject will get updated to after the batch has been processed.
38+
latest_event_status (str | list): The status the subject will get updated to after the batch has been processed.
3939
run_timed_events (bool): An optional input that executes bcss_timed_events if set to True
4040
get_subjects_from_pdf (bool): An optional input to change the method of retrieving subjects from the batch from the DB to the PDF file.
4141
"""

utils/screening_subject_page_searcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def verify_subject_event_status_by_nhs_no(
13-
page: Page, nhs_no: str, latest_event_status: str
13+
page: Page, nhs_no: str, latest_event_status: str | list
1414
) -> None:
1515
"""
1616
This is used to check that the latest event status of a subject has been updated to what is expected

0 commit comments

Comments
 (0)