Skip to content

Commit 2886015

Browse files
adrianoaru-nhsAndyg79
authored andcommitted
Migrating scenario 12 from the EndoscopyInvestigationDatasetScenarios feature file (#117)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> Migrating scenario 12 from the EndoscopyInvestigationDatasetScenarios feature file ## Context <!-- Why is this change required? What problem does it solve? --> Migrating scenario 12 from the EndoscopyInvestigationDatasetScenarios feature file ## 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) - [x] 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 - [x] 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 93e5f43 commit 2886015

File tree

3 files changed

+988
-283
lines changed

3 files changed

+988
-283
lines changed

pages/datasets/investigation_dataset_page.py

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -713,33 +713,49 @@ def label_matches(idx: int) -> bool:
713713

714714
def check_visibility_of_drug_type(
715715
self, drug_type: str, drug_number: int, visible: bool
716-
) -> bool:
716+
) -> None:
717717
"""
718718
Checks the visibility of the drug type input cell.
719719
Args:
720720
drug_type (str): The drug type to check
721721
drug_number (int): The number of the drug type cell to check.
722722
expected_text (str): The expected text content of the cell.
723-
Returns:
724-
bool: True if the visibility matches the expectation, False otherwise.
723+
Raises:
724+
AssertionError: If the visibility does not match the expectation.
725725
"""
726726
locator = self.get_drug_type_locator(drug_type, drug_number)
727-
return locator.is_visible() == visible
727+
actual_visibility = locator.is_visible()
728+
assert actual_visibility == visible, (
729+
f"The {ordinal(drug_number)} {drug_type} drug type input cell visibility was {actual_visibility}, "
730+
f"expected {visible}"
731+
)
732+
logging.info(
733+
f"The {ordinal(drug_number)} {drug_type} drug type input cell is "
734+
f"{'visible' if actual_visibility else 'not visible'} as expected"
735+
)
728736

729737
def check_visibility_of_drug_dose(
730738
self, drug_type: str, drug_number: int, visible: bool
731-
) -> bool:
739+
) -> None:
732740
"""
733-
Checks the visibility of the drug dose input cell.
741+
Asserts the visibility of the drug dose input cell and logs the result.
734742
Args:
735-
drug_type (str): The drug type to check
743+
drug_type (str): The drug type to check.
736744
drug_number (int): The number of the drug dose cell to check.
737745
visible (bool): True if the field should be visible, False if it should not.
738-
Returns:
739-
bool: True if the visibility matches the expectation, False otherwise.
746+
Raises:
747+
AssertionError: If the visibility does not match the expectation.
740748
"""
741749
locator = self.get_drug_dose_locator(drug_type, drug_number)
742-
return locator.is_visible() == visible
750+
actual_visibility = locator.is_visible()
751+
assert actual_visibility == visible, (
752+
f"The {ordinal(drug_number)} {drug_type} drug dose input cell visibility was {actual_visibility}, "
753+
f"expected {visible}"
754+
)
755+
logging.info(
756+
f"The {ordinal(drug_number)} {drug_type} drug dose input cell is "
757+
f"{'visible' if actual_visibility else 'not visible'} as expected"
758+
)
743759

744760
def assert_drug_type_text(
745761
self, drug_type: str, drug_number: int, expected_text: str
@@ -928,8 +944,23 @@ def assert_all_drug_information(
928944
| AntibioticsAdministeredDrugTypeOptions.GENTAMICIN
929945
| AntibioticsAdministeredDrugTypeOptions.METRONIDAZOLE
930946
| AntibioticsAdministeredDrugTypeOptions.TEICOPLANIN
947+
| OtherDrugsAdministeredDrugTypeOptions.BUSCOPAN
948+
| OtherDrugsAdministeredDrugTypeOptions.DIAZEMULS
949+
| OtherDrugsAdministeredDrugTypeOptions.GLUCAGON
950+
| OtherDrugsAdministeredDrugTypeOptions.HYDROCORTISONE
951+
| OtherDrugsAdministeredDrugTypeOptions.MEPTAZINOL
952+
| OtherDrugsAdministeredDrugTypeOptions.MIDAZOLAM
953+
| OtherDrugsAdministeredDrugTypeOptions.PETHIDINE
954+
| OtherDrugsAdministeredDrugTypeOptions.PROPOFOL
931955
):
932956
expected_unit = "mg"
957+
case (
958+
OtherDrugsAdministeredDrugTypeOptions.ALFENTANYL
959+
| OtherDrugsAdministeredDrugTypeOptions.FENTANYL
960+
| OtherDrugsAdministeredDrugTypeOptions.FLUMAZENIL
961+
| OtherDrugsAdministeredDrugTypeOptions.NALOXONE
962+
):
963+
expected_unit = "mcg"
933964
case _:
934965
expected_unit = None
935966

@@ -1369,6 +1400,23 @@ class AntibioticsAdministeredDrugTypeOptions(StrEnum):
13691400
OTHER_ANTIBIOTIC = "305493"
13701401

13711402

1403+
class OtherDrugsAdministeredDrugTypeOptions(StrEnum):
1404+
"""Enum for other drugs administered drug type options"""
1405+
1406+
ALFENTANYL = "200252~mcg"
1407+
BUSCOPAN = "17133~mg"
1408+
DIAZEMULS = "17959~mg"
1409+
FENTANYL = "17958~mcg"
1410+
FLUMAZENIL = "17134~mcg"
1411+
GLUCAGON = "17940~mg"
1412+
HYDROCORTISONE = "17527~mg"
1413+
MEPTAZINOL = "200251~mg"
1414+
MIDAZOLAM = "17135~mg"
1415+
NALOXONE = "17136~mcg~204333"
1416+
PETHIDINE = "17137~mg"
1417+
PROPOFOL = "17960~mg"
1418+
1419+
13721420
# Registry of all known Enums to search when matching string values
13731421
ALL_ENUMS: List[type[Enum]] = [
13741422
obj
@@ -1412,3 +1460,14 @@ def to_enum_name_or_value(val: Any) -> Union[str, Any]:
14121460

14131461
# Fallback: return unchanged
14141462
return val
1463+
1464+
1465+
def ordinal(n: int) -> str:
1466+
"""
1467+
Converts an integer to its ordinal representation (e.g., 1 -> '1st', 2 -> '2nd').
1468+
"""
1469+
if 10 <= n % 100 <= 20:
1470+
suffix = "th"
1471+
else:
1472+
suffix = {1: "st", 2: "nd", 3: "rd"}.get(n % 10, "th")
1473+
return f"{n}{suffix}"

0 commit comments

Comments
 (0)