Skip to content

Commit 950e552

Browse files
committed
working on FOBT scenario 14
1 parent bc9747d commit 950e552

File tree

4 files changed

+1028
-1054
lines changed

4 files changed

+1028
-1054
lines changed

classes/repositories/subject_repository.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,58 @@ def get_matching_subject(
225225
except Exception:
226226
raise ValueError("No subject found matching the given criteria")
227227
return subject
228+
229+
def there_is_letter_batch_for_subject(
230+
self,
231+
nhs_no: str,
232+
letter_batch_code: str,
233+
letter_batch_title: str,
234+
assertion: bool = True,
235+
) -> None:
236+
"""
237+
Checks if the subject under test has a specific letter batch assosiated with them.
238+
Args:
239+
nhs_no (str): The subject's NHS number.
240+
letter_batch_code (str): The letter batch code.
241+
letter_batch_title (str): The letter batch title.
242+
assertion (bool): If the subject should have this batch (True), or should not have this batch (False).
243+
"""
244+
sql_query = """ SELECT lb.batch_id
245+
FROM lett_batch_records lbr
246+
INNER JOIN lett_batch lb
247+
ON lb.batch_id = lbr.batch_id
248+
INNER JOIN valid_values ld
249+
ON ld.valid_value_id = lb.description_id
250+
INNER JOIN valid_values lbs
251+
ON lbs.valid_value_id = lb.status_id
252+
WHERE lb.batch_state_id = 12018
253+
AND lbr.screening_subject_id = :subject_id
254+
AND lbs.allowed_value = :batch_code
255+
AND LOWER(ld.description) = LOWER(:batch_title)
256+
AND lbr.non_inclusion_id IS NULL
257+
AND lbr.key_id != 11539
258+
"""
259+
260+
subject_id = self.oracle_db.get_subject_id_from_nhs_number(nhs_no)
261+
262+
params = {
263+
"subject_id": subject_id,
264+
"batch_code": letter_batch_code,
265+
"batch_title": letter_batch_title,
266+
}
267+
268+
batch_df = self.oracle_db.execute_query(sql_query, params)
269+
if assertion:
270+
assert (
271+
not batch_df.empty
272+
), f"[DB ASSERTION FAILED] Subject {nhs_no} does not have a {letter_batch_code} - {letter_batch_title} batch when they are expected to"
273+
logging.info(
274+
f"[DB ASSERTION Passed] Subject {nhs_no} has a {letter_batch_code} - {letter_batch_title} batch"
275+
)
276+
else:
277+
assert (
278+
batch_df.empty
279+
), f"[DB ASSERTION FAILED] Subject {nhs_no} has a {letter_batch_code} - {letter_batch_title} batch when they are expected not to"
280+
logging.info(
281+
f"[DB ASSERTION Passed] Subject {nhs_no} does not have a {letter_batch_code} - {letter_batch_title} batch"
282+
)

pages/screening_subject_search/result_from_symptomatic_procedure_page.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def __init__(self, page: Page):
1515
"#UI_SURGERY_DATE__LinkOrButton"
1616
)
1717
self.alert_textbox = self.page.locator("#UI_SPAN_RECALL_TEXT")
18-
self.all_tests = self.page.locator("#UI_ID_RECALL_ANCHOR_DATE_EXT_TEST_ID")
18+
self.all_tests = self.page.locator(
19+
"[id^='UI_ID_RECALL_ANCHOR_DATE_EXT_TEST_ID']"
20+
)
1921
self.save_button = self.page.get_by_role("button", name="Save")
2022

2123
def click_date_of_symptomatic_procedure_calendar_button(self) -> None:

0 commit comments

Comments
 (0)