Skip to content

Commit f37cb49

Browse files
committed
updating util and adding markdown document
1 parent cdf7eee commit f37cb49

File tree

2 files changed

+30
-58
lines changed

2 files changed

+30
-58
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Utility Guide: Note Test Utilities
2+
3+
The **Note Test Utility** module provides reusable helper functions for verifying and comparing note data during test automation of screening subjects in BCSS.
4+
It includes helpers for:
5+
6+
1. Searching for a subject by NHS number.
7+
2. Fetching supporting notes from the database.
8+
3. Verifying that a note matches expected values from the DB or UI.
9+
4. Confirming that a removed note is archived properly as obsolete.
10+
11+
## Table of Contents
12+
13+
- [Utility Guide: Note Test Utilities](#utility-guide-note-test-utilities)
14+
- [Table of Contents](#table-of-contents)
15+
- [Using These Utilities](#using-these-utilities)
16+
17+
---
18+
19+
## Using These Utilities
20+
21+
You can import functions into your test files like so:
22+
23+
```python
24+
from utils.note_test_util import (
25+
search_subject_by_nhs,
26+
fetch_supporting_notes_from_db,
27+
verify_note_content_matches_expected,
28+
verify_note_content_ui_vs_db,
29+
verify_note_removal_and_obsolete_transition,
30+
)

utils/subject_notes.py

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -132,64 +132,6 @@ def verify_note_content_ui_vs_db(
132132
), f"Note does not match. UI: '{ui_data['note']}', DB: '{db_data['note']}'"
133133

134134

135-
def verify_note_removed_and_archived(
136-
page: Page, subjects_df: pd.DataFrame, ui_data: dict, general_properties: dict
137-
) -> None:
138-
"""
139-
Verifies that a note has been removed from active notes and archived under obsolete notes.
140-
141-
:param page: The current Page object
142-
:param subjects_df: DataFrame containing subject IDs
143-
:param ui_data: Dict with keys 'title' and 'note' from UI
144-
:param general_properties: Dictionary with system config (note type/status)
145-
"""
146-
screening_subject_id = int(subjects_df["screening_subject_id"].iloc[0])
147-
logging.info(f"Screening Subject ID retrieved: {screening_subject_id}")
148-
149-
removed_note_title = ui_data["title"].strip()
150-
removed_note_text = ui_data["note"].strip()
151-
152-
# Validate removed note is NOT in active notes
153-
notes_df_active = get_supporting_notes(
154-
screening_subject_id,
155-
general_properties["additional_care_note_type_value"],
156-
general_properties["note_status_active"],
157-
)
158-
logging.info("Verifying removed note is not present in active notes.")
159-
for _, row in notes_df_active.iterrows():
160-
db_title = row["title"].strip()
161-
db_note = row["note"].strip()
162-
logging.info(f"Checking active note: Title='{db_title}', Note='{db_note}'")
163-
164-
assert (
165-
db_title != removed_note_title or db_note != removed_note_text
166-
), f"Removed note is still present in active notes. Title: '{db_title}', Note: '{db_note}'"
167-
168-
logging.info("✔️ Removed note confirmed not present among active notes.")
169-
170-
# Validate removed note IS in obsolete notes
171-
notes_df_obsolete = get_supporting_notes(
172-
screening_subject_id,
173-
general_properties["additional_care_note_type_value"],
174-
general_properties["note_status_obsolete"],
175-
)
176-
logging.info("Verifying removed note is present among obsolete notes.")
177-
found = False
178-
for _, row in notes_df_obsolete.iterrows():
179-
db_title = row["title"].strip()
180-
db_note = row["note"].strip()
181-
logging.info(f"Checking obsolete note: Title='{db_title}', Note='{db_note}'")
182-
if db_title == removed_note_title and db_note == removed_note_text:
183-
found = True
184-
break
185-
186-
assert found, (
187-
f"Removed note is not present in the obsolete list. "
188-
f"Title: '{removed_note_title}', Note: '{removed_note_text}'"
189-
)
190-
logging.info("✅ Verification successful: Removed note is now archived.")
191-
192-
193135
def verify_note_removal_and_obsolete_transition(
194136
subjects_df: pd.DataFrame,
195137
ui_data: dict,

0 commit comments

Comments
 (0)