Skip to content

Commit bf6b575

Browse files
Batch Processing Util Rework (#62)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> Refactored the batch processing util to allow the latest_event_Status to be passed on as a list. ## Context <!-- Why is this change required? What problem does it solve? --> As some batches have subjects with different statuses, this allows us to check for all of the statuses against a subject. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [ ] I have added tests to cover my changes (where appropriate) - [x] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
1 parent 3cebb32 commit bf6b575

File tree

4 files changed

+34
-13
lines changed

4 files changed

+34
-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 different 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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,36 @@ 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(
89+
latest_event_status_locator = self.get_visible_status_from_list(
9190
latest_event_status
9291
)
92+
status = latest_event_status_locator.inner_text()
93+
logging.info(f"Verifying subject has the status: {status}")
9394
try:
94-
expect(latest_event_status_cell).to_be_visible()
95-
logging.info(f"Subject has the status: {latest_event_status}")
95+
expect(latest_event_status_locator).to_be_visible()
96+
logging.info(f"Subject has the status: {status}")
9697
except Exception:
97-
pytest.fail(f"Subject does not have the status: {latest_event_status}")
98+
pytest.fail(f"Subject does not have the status: {status}")
99+
100+
def get_visible_status_from_list(self, latest_event_status) -> Locator:
101+
"""
102+
Get the first visible status from the latest event status string or list.
103+
104+
Args:
105+
latest_event_status (str | list): The latest event status to check.
106+
107+
Returns:
108+
Locator: The locator for the first visible status.
109+
"""
110+
if isinstance(latest_event_status, str):
111+
latest_event_status = [latest_event_status]
112+
for status in latest_event_status:
113+
locator = self.page.get_by_role("cell", name=status, exact=True)
114+
if locator.is_visible():
115+
return locator
116+
logging.error("Unable to find any of the listed statuses")
98117

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

utils/batch_processing.py

Lines changed: 6 additions & 4 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
"""
@@ -79,8 +79,10 @@ def batch_processing(
7979

8080
check_batch_in_archived_batch_list(page, link_text)
8181

82-
first_nhs_no = nhs_no_df["subject_nhs_number"].iloc[0]
83-
verify_subject_event_status_by_nhs_no(page, first_nhs_no, latest_event_status)
82+
for subject in range(len(nhs_no_df)):
83+
nhs_no = nhs_no_df["subject_nhs_number"].iloc[subject]
84+
logging.info(f"Verifying the event status for subject: {nhs_no}")
85+
verify_subject_event_status_by_nhs_no(page, nhs_no, latest_event_status)
8486

8587
if run_timed_events:
8688
OracleDB().exec_bcss_timed_events(nhs_no_df)

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)