Skip to content

Commit 8ee2e27

Browse files
Added more logging
1 parent 75f598a commit 8ee2e27

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

pages/datasets/investigation_dataset_page.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import re
22
from playwright.sync_api import Page, expect, Locator
33
from pages.base_page import BasePage
4-
from enum import StrEnum
4+
from enum import Enum, StrEnum
55
from utils.oracle.oracle_specific_functions import (
66
get_investigation_dataset_polyp_category,
77
get_investigation_dataset_polyp_algorithm_size,
88
)
99
from typing import Optional, Any, Union, List
1010
import logging
11-
from enum import Enum
11+
import sys
1212

1313

1414
class InvestigationDatasetsPage(BasePage):
@@ -1326,8 +1326,14 @@ class AntibioticsAdministeredDrugTypeOptions(StrEnum):
13261326

13271327
# Registry of all known Enums to search when matching string values
13281328
ALL_ENUMS: List[type[Enum]] = [
1329-
DrugTypeOptions,
1330-
AntibioticsAdministeredDrugTypeOptions,
1329+
obj
1330+
for obj in globals().values()
1331+
if (
1332+
isinstance(obj, type)
1333+
and issubclass(obj, Enum)
1334+
and obj is not Enum
1335+
and obj is not StrEnum # Exclude only the base classes, not subclasses
1336+
)
13311337
]
13321338

13331339

utils/dataset_field_util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from playwright.sync_api import Page, Locator
22
from typing import Optional, List
33
import logging
4+
from pages.datasets.investigation_dataset_page import (
5+
to_enum_name_or_value,
6+
)
47

58

69
class DatasetFieldUtil:
@@ -25,6 +28,7 @@ def populate_input_locator_for_field(self, text: str, value: str) -> None:
2528
text (str): The text of the element you want to get the input locator of
2629
value (str): The value you want to input
2730
"""
31+
logging.info(f"Filling input for field '{text}' with value '{value}'")
2832
locator = self.get_input_locator_for_field(text)
2933
locator.fill(value)
3034

@@ -45,6 +49,9 @@ def populate_select_locator_for_field(self, text: str, option: str) -> None:
4549
text (str): The text of the element you want to get the select locator of.
4650
option (str): The option you want to select
4751
"""
52+
logging.info(
53+
f"Selecting option '{to_enum_name_or_value(option)}' for field '{text}'"
54+
)
4855
locator = self.get_select_locator_for_field(text)
4956
locator.select_option(option)
5057

@@ -70,6 +77,7 @@ def populate_input_locator_for_field_inside_div(
7077
div (str): The ID of the DIV the text belongs in
7178
value (str): The value you want to input
7279
"""
80+
logging.info(f"Filling input for field '{text}' with value '{value}'")
7381
locator = self.get_input_locator_for_field_inside_div(text, div)
7482
locator.fill(value)
7583

@@ -95,6 +103,9 @@ def populate_select_locator_for_field_inside_div(
95103
div (str): The ID of the DIV the text belongs in
96104
option (str): The option you want to select
97105
"""
106+
logging.info(
107+
f"Selecting option '{to_enum_name_or_value(option)}' for field '{text}'"
108+
)
98109
locator = self.get_select_locator_for_field_inside_div(text, div)
99110
locator.select_option(option)
100111

utils/investigation_dataset.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
PolypInterventionModalityOptions,
4040
PolypInterventionDeviceOptions,
4141
PolypInterventionExcisionTechniqueOptions,
42+
to_enum_name_or_value,
4243
)
4344
from pages.screening_subject_search.advance_fobt_screening_episode_page import (
4445
AdvanceFOBTScreeningEpisodePage,
@@ -408,32 +409,38 @@ def fill_out_drug_information(self, drug_information: dict) -> None:
408409
for key, value in drug_information.items():
409410
if key.startswith("drug_type"):
410411
index = key[len("drug_type") :]
411-
logging.info(f"Adding drug type {index}")
412+
logging.info(
413+
f"Adding drug type {index}: {to_enum_name_or_value(value)}"
414+
)
412415
select_locator = f"#UI_BOWEL_PREP_DRUG{index}"
413416
self.page.select_option(select_locator, value)
414417
elif key.startswith("drug_dose"):
415418
index = key[len("drug_dose") :]
416-
logging.info(f"Adding drug dose {index}")
419+
logging.info(f"Adding drug dose {index}: {value}")
417420
input_locator = f"#UI_BOWEL_PREP_DRUG_DOSE{index}"
418421
self.page.fill(input_locator, value)
419422
elif key.startswith("antibiotic_drug_type"):
420423
index = key[len("antibiotic_drug_type") :]
421-
logging.info(f"Adding antibiotic drug type {index}")
424+
logging.info(
425+
f"Adding antibiotic drug type {index}: {to_enum_name_or_value(value)}"
426+
)
422427
select_locator = f"#UI_ANTIBIOTIC{index}"
423428
self.page.select_option(select_locator, value)
424429
elif key.startswith("antibiotic_drug_dose"):
425430
index = key[len("antibiotic_drug_dose") :]
426-
logging.info(f"Adding antibiotic drug dose {index}")
431+
logging.info(f"Adding antibiotic drug dose {index}: {value}")
427432
input_locator = f"#UI_ANTIBIOTIC_DOSE{index}"
428433
self.page.fill(input_locator, value)
429434
elif key.startswith("other_drug_type"):
430435
index = key[len("other_drug_type") :]
431-
logging.info(f"Adding other drug type {index}")
436+
logging.info(
437+
f"Adding other drug type {index}: {to_enum_name_or_value(value)}"
438+
)
432439
select_locator = f"#UI_DRUG{index}"
433440
self.page.select_option(select_locator, value)
434441
elif key.startswith("other_drug_dose"):
435442
index = key[len("other_drug_dose") :]
436-
logging.info(f"Adding other drug dose {index}")
443+
logging.info(f"Adding other drug dose {index}: {value}")
437444
input_locator = f"#UI_DOSE{index}"
438445
self.page.fill(input_locator, value)
439446

0 commit comments

Comments
 (0)