Skip to content

Commit 45ee855

Browse files
Addressing PR comment
1 parent 8ee2e27 commit 45ee855

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

pages/datasets/investigation_dataset_page.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,46 @@ def assert_drug_dose_unit_text(
972972
actual_text == expected_text
973973
), f"Expected drug unit dose text '{expected_text}' but found '{actual_text}'"
974974

975+
def assert_drug_dosage_unit_text(
976+
self, drug_type: str, drug_number: int, expected_text: str
977+
) -> None:
978+
"""
979+
Asserts that the drug dosage unit contains the expected text.
980+
981+
Args:
982+
drug_type (str): The drug type to check
983+
drug_number (int): The number of the drug dosage unit cell to check.
984+
expected_text (str): The expected text content of the cell.
985+
986+
Raises:
987+
AssertionError: If the actual text does not match the expected text.
988+
"""
989+
locator = self.get_drug_dosage_text_locator(drug_type, drug_number)
990+
actual_text = locator.inner_text().strip()
991+
992+
logging.info(
993+
f"Drug dosage unit text for drug {drug_number}: "
994+
f"'{actual_text}' (expected: '{expected_text}')"
995+
)
996+
997+
assert actual_text == expected_text, (
998+
f"Expected drug dosage unit text '{expected_text}' "
999+
f"but found '{actual_text}'"
1000+
)
1001+
1002+
def get_drug_dosage_text_locator(self, drug_type: str, drug_number: int) -> Locator:
1003+
"""
1004+
Returns the drug dosage text locator for the matching drug type and number
1005+
Args:
1006+
drug_type (str): The drug type to check
1007+
drug_number (int): The number of the drug to check
1008+
"""
1009+
if drug_type.lower() == "bowel preparation administered":
1010+
locator_prefix = "#HILITE_spanBowelPrepDrugDosageUnit"
1011+
elif drug_type.lower() == "antibiotics administered":
1012+
locator_prefix = "#HILITE_spanAntibioticDosageUnit"
1013+
return self.page.locator(f"{locator_prefix}{drug_number}")
1014+
9751015

9761016
def normalize_label(text: str) -> str:
9771017
"""

tests/regression/subject/episodes/datasets/investigation/endoscopy/test_endoscopy_investigation_dataset_scenarios.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,11 @@ def test_check_behaviour_of_antibiotics_administered_fields_in_incomplete_datase
15491549
InvestigationDatasetsPage(page).assert_all_drug_information(
15501550
drug_information, "Antibiotics Administered"
15511551
)
1552+
InvestigationDatasetsPage(page).assert_drug_dosage_unit_text(
1553+
"Antibiotics Administered",
1554+
9,
1555+
"Please record antibiotic details and dosage in episode notes.",
1556+
)
15521557
LogoutPage(page).log_out()
15531558

15541559

0 commit comments

Comments
 (0)