diff --git a/conftest.py b/conftest.py index a4ef481e1c6..f9381e29a23 100644 --- a/conftest.py +++ b/conftest.py @@ -5,7 +5,7 @@ from libs import CurrentExecution as ce from libs import file_ops as fo -from libs.generic_constants import audit_log_paths, file_mode, fixture_scope +from libs.generic_constants import audit_log_paths, file_mode from libs.mavis_constants import browsers_and_devices, playwright_constants from libs.wrappers import * @@ -14,7 +14,7 @@ def pytest_addoption(parser): parser.addoption("--browser_or_device", action="store", default=browsers_and_devices.CHROMIUM) -@pytest.fixture(scope=fixture_scope.SESSION) +@pytest.fixture(scope="session") def start_playwright_session(request): ce.get_env_values() ce.reset_environment() @@ -26,7 +26,7 @@ def start_playwright_session(request): # ce.reset_environment() # Clean up the environment after execution -@pytest.fixture(scope=fixture_scope.FUNCTION) +@pytest.fixture(scope="function") def start_mavis(start_playwright_session): _browser, _context = start_browser(pw=start_playwright_session, browser_or_device=ce.current_browser_name) ce.browser = _browser @@ -42,6 +42,8 @@ def create_session_screenshot_dir() -> str: _session_name = f"{get_current_datetime()}-{ce.current_browser_name}" fo.file_operations().create_dir(dir_path=f"screenshots/{_session_name}") return f"screenshots/{_session_name}" + else: + return "" def start_browser(pw, browser_or_device: str): diff --git a/libs/__init__.py b/libs/__init__.py index da4cdd82183..10e9957ce92 100644 --- a/libs/__init__.py +++ b/libs/__init__.py @@ -10,24 +10,26 @@ class CurrentExecution: page = None browser = None - service_url: str = "" - base_auth_username: str = "" - base_auth_password: str = "" - current_browser_name: str = "" - headless_mode: bool = False - session_screenshots_dir: str = "" + service_url: str | None = "" + base_auth_username: str | None = "" + base_auth_password: str | None = "" + current_browser_name: str | None = "" + headless_mode: bool | None = False + session_screenshots_dir: str | None = "" + + capture_screenshot_flag: bool | None = False + nurse_username: str | None = "" + nurse_password: str | None = "" + superuser_username: str | None = "" + superuser_password: str | None = "" + admin_username: str | None = "" + admin_password: str | None = "" + reset_endpoint: str | None = "" + api_token: str | None = "" + reset_env_before_execution: bool | None = False + slow_motion: int | None = 0 + screenshot_sequence: int = 0 - capture_screenshot_flag: bool = False - nurse_username: str = "" - nurse_password: str = "" - superuser_username: str = "" - superuser_password: str = "" - admin_username: str = "" - admin_password: str = "" - reset_endpoint: str = "" - api_token: str = "" - reset_env_before_execution: bool = False - slow_motion: int = 0 child_list: list[str] = [] file_record_count: int = 0 session_id: str = "" @@ -44,12 +46,12 @@ def get_env_values(): CurrentExecution.superuser_password = os.getenv("SUPERUSER_PASSWORD") CurrentExecution.admin_username = os.getenv("ADMIN_USERNAME") CurrentExecution.admin_password = os.getenv("ADMIN_PASSWORD") - CurrentExecution.headless_mode = os.getenv("HEADLESS").lower() == "true" - CurrentExecution.capture_screenshot_flag = os.getenv("CAPTURE_SCREENSHOTS").lower() == "true" + CurrentExecution.headless_mode = os.getenv("HEADLESS", "True").lower() == "true" + CurrentExecution.capture_screenshot_flag = os.getenv("CAPTURE_SCREENSHOTS", "True").lower() == "true" CurrentExecution.reset_endpoint = f"{CurrentExecution.service_url}{os.getenv('RESET_ENDPOINT')}" CurrentExecution.api_token = os.getenv("API_TOKEN") - CurrentExecution.reset_env_before_execution = os.getenv("RESET_ENV_BEFORE_EXECUTION").lower() == "true" - CurrentExecution.slow_motion = int(os.getenv("SLOW_MOTION")) + CurrentExecution.reset_env_before_execution = os.getenv("RESET_ENV_BEFORE_EXECUTION", "True").lower() == "true" + CurrentExecution.slow_motion = int(os.getenv("SLOW_MOTION", 0)) @staticmethod def reset_environment(): @@ -80,5 +82,5 @@ def set_session_id(session_id: str): CurrentExecution.session_id = session_id @staticmethod - def get_session_id() -> int: + def get_session_id() -> str: return CurrentExecution.session_id diff --git a/libs/file_ops.py b/libs/file_ops.py index 526c418907c..2202c393335 100644 --- a/libs/file_ops.py +++ b/libs/file_ops.py @@ -49,8 +49,10 @@ def get_file_text(self, file_path: str) -> str: str: Text content of the file. """ if self.check_if_path_exists(file_or_folder_path=file_path): - with open(file=file_path, mode=file_mode.READ) as f: + with open(file=file_path, mode=file_mode.READ, encoding="utf-8") as f: return f.read() + else: + assert False, f"Cannot read file. File not found: {file_path}" def read_csv_to_df(self, file_path: str) -> pd.DataFrame: """ @@ -64,6 +66,8 @@ def read_csv_to_df(self, file_path: str) -> pd.DataFrame: """ if self.check_if_path_exists(file_or_folder_path=file_path): return pd.read_csv(filepath_or_buffer=file_path) + else: + assert False, f"Cannot read CSV file. File not found: {file_path}" def read_excel_to_df(self, file_path: str, sheet_name: str) -> pd.DataFrame: """ @@ -93,6 +97,6 @@ def create_file(self, content: str, file_name_prefix: str = "") -> str: str: Path to the created file. """ _file_name = f"working/{file_name_prefix}{get_current_datetime()}.csv" - with open(file=_file_name, mode=file_mode.WRITE) as f: + with open(file=_file_name, mode=file_mode.WRITE, encoding="utf-8") as f: f.writelines(content) return _file_name diff --git a/libs/generic_constants.py b/libs/generic_constants.py index 2b048076687..d65b4134e51 100644 --- a/libs/generic_constants.py +++ b/libs/generic_constants.py @@ -1,38 +1,34 @@ +from enum import Enum, auto from typing import Final -class fixture_scope: - SESSION: Final[str] = "session" - FUNCTION: Final[str] = "function" - - -class element_properties: - TEXT: Final[str] = "text" - VISIBILITY: Final[str] = "visibility" - HREF: Final[str] = "href" - ELEMENT_EXISTS: Final[str] = "element_exists" - PAGE_URL: Final[str] = "page_url" - CHECKBOX_CHECKED: Final[str] = "checked" - - -class framework_actions: - CLICK_LINK: Final[str] = "click_link" - CLICK_BUTTON: Final[str] = "click_button" - CLICK_LABEL: Final[str] = "click_label" - CLICK_TEXT: Final[str] = "click_text" - FILL: Final[str] = "fill" - TYPE: Final[str] = "type" - RADIO_BUTTON_SELECT: Final[str] = "radio_select" - SELECT_FILE: Final[str] = "select_file" - SELECT_FROM_LIST: Final[str] = "select_from_list" - CHECKBOX_CHECK: Final[str] = "checkbox_check" - CHECKBOX_UNCHECK: Final[str] = "checkbox_uncheck" - CLICK_LINK_INDEX_FOR_ROW: Final[str] = "click_link_index_for_row" - CLICK_WILDCARD: Final[str] = "click_wildcard" - CHAIN_LOCATOR_ACTION: Final[str] = "chain_locator" - DOWNLOAD_FILE_USING_LINK: Final[str] = "download_file_using_link" - DOWNLOAD_FILE_USING_BUTTON: Final[str] = "download_file_using_button" - WAIT: Final[str] = "wait" +class element_properties(Enum): + TEXT = auto() + VISIBILITY = auto() + HREF = auto() + ELEMENT_EXISTS = auto() + PAGE_URL = auto() + CHECKBOX_CHECKED = auto() + + +class framework_actions(Enum): + CLICK_LINK = auto() + CLICK_BUTTON = auto() + CLICK_LABEL = auto() + CLICK_TEXT = auto() + FILL = auto() + TYPE = auto() + RADIO_BUTTON_SELECT = auto() + SELECT_FILE = auto() + SELECT_FROM_LIST = auto() + CHECKBOX_CHECK = auto() + CHECKBOX_UNCHECK = auto() + CLICK_LINK_INDEX_FOR_ROW = auto() + CLICK_WILDCARD = auto() + CHAIN_LOCATOR_ACTION = auto() + DOWNLOAD_FILE_USING_LINK = auto() + DOWNLOAD_FILE_USING_BUTTON = auto() + WAIT = auto() class screenshot_actions: diff --git a/libs/mavis_constants.py b/libs/mavis_constants.py index f49f1a8f55d..4b6a33cac76 100644 --- a/libs/mavis_constants.py +++ b/libs/mavis_constants.py @@ -1,3 +1,4 @@ +from enum import Enum, auto from typing import Final @@ -34,11 +35,11 @@ class programmes: class vaccines: - GARDASIL9: Final[str] = ("Gardasil9", 0) # HPV - MENQUADFI: Final[str] = ("MenQuadfi", 1) # MenACWY - MENVEO: Final[str] = ("Menveo", 2) # MenACWY - NIMENRIX: Final[str] = ("Nimenrix", 3) # MenACWY - REVAXIS: Final[str] = ("Revaxis", 4) # Td/IPV + GARDASIL9: Final[tuple[str, int]] = ("Gardasil9", 0) # HPV + MENQUADFI: Final[tuple[str, int]] = ("MenQuadfi", 1) # MenACWY + MENVEO: Final[tuple[str, int]] = ("Menveo", 2) # MenACWY + NIMENRIX: Final[tuple[str, int]] = ("Nimenrix", 3) # MenACWY + REVAXIS: Final[tuple[str, int]] = ("Revaxis", 4) # Td/IPV class test_data_values: @@ -49,12 +50,12 @@ class test_data_values: EMPTY: Final[str] = "" -class mavis_file_types: - CHILD_LIST: Final[str] = "childlist" - COHORT: Final[str] = "cohort" - CLASS_LIST: Final[str] = "classlist" - VACCS_MAVIS: Final[str] = "vaccsmavis" - VACCS_SYSTMONE: Final[str] = "vaccssystmone" +class mavis_file_types(Enum): + CHILD_LIST = auto() + COHORT = auto() + CLASS_LIST = auto() + VACCS_MAVIS = auto() + VACCS_SYSTMONE = auto() class record_limit: @@ -80,6 +81,8 @@ class test_data_file_paths: VACCS_SYSTMONE_POSITIVE: Final[str] = "VACCS_SYSTMONE_POSITIVE" VACCS_SYSTMONE_NEGATIVE: Final[str] = "VACCS_SYSTMONE_NEGATIVE" VACCS_SYSTMONE_HIST_NEGATIVE: Final[str] = "VACCS_SYSTMONE_HIST_NEGATIVE" + VACCS_MAV_1080: Final[str] = "VACCS_MAV_1080" + VACCS_SYSTMONE_MAV_1080: Final[str] = "VACCS_SYSTMONE_MAV_1080" COHORTS_POSITIVE: Final[str] = "COHORTS_POSITIVE" COHORTS_NEGATIVE: Final[str] = "COHORTS_NEGATIVE" COHORTS_INVALID_STRUCTURE: Final[str] = "COHORTS_INVALID_STRUCTURE" @@ -102,6 +105,7 @@ class test_data_file_paths: CLASS_SINGLE_VACC: Final[str] = "CLASS_SINGLE_VACC" CLASS_MAV_854: Final[str] = "CLASS_MAV_854" CLASS_MAV_965: Final[str] = "CLASS_MAV_965" + CLASS_MAV_1080: Final[str] = "CLASS_MAV_1080" COHORTS_NO_CONSENT: Final[str] = "COHORTS_NO_CONSENT" COHORTS_CONFLICTING_CONSENT: Final[str] = "COHORTS_CONFLICTING_CONSENT" COHORTS_E2E_1: Final[str] = "COHORTS_E2E_1" @@ -119,7 +123,7 @@ class test_data_file_paths: class report_headers: CAREPLUS: Final[str] = ( - "NHS Number,Surname,Forename,Date of Birth,Address Line 1,Person Giving Consent,Ethnicity,Date Attended,Time Attended,Venue Type,Venue Code,Staff Type,Staff Code,Attended,Reason Not Attended,Suspension End Date,Vaccine 1,Dose 1,Reason Not Given 1,Site 1,Manufacturer 1,Batch No 1,Vaccine 2,Dose 2,Reason Not Given 2,Site 2,Manufacturer 2,Batch No 2,Vaccine 3,Dose 3,Reason Not Given 3,Site 3,Manufacturer 3,Batch No 3,Vaccine 4,Dose 4,Reason Not Given 4,Site 4,Manufacturer 4,Batch No 4,Vaccine 5,Dose 5,Reason Not Given 5,Site 5,Manufacturer 5,Batch No 5" + "NHS Number,Surname,Forename,Date of Birth,Address Line 1,Person Giving Consent,Ethnicity,Date Attended,Time Attended,Venue Type,Venue Code,Staff Type,Staff Code,Attended,Reason Not Attended,Suspension End Date,Vaccine 1,Vaccine Code 1,Dose 1,Reason Not Given 1,Site 1,Manufacturer 1,Batch No 1,Vaccine 2,Vaccine Code 2,Dose 2,Reason Not Given 2,Site 2,Manufacturer 2,Batch No 2,Vaccine 3,Vaccine Code 3,Dose 3,Reason Not Given 3,Site 3,Manufacturer 3,Batch No 3,Vaccine 4,Vaccine Code 4,Dose 4,Reason Not Given 4,Site 4,Manufacturer 4,Batch No 4,Vaccine 5,Vaccine Code 5,Dose 5,Reason Not Given 5,Site 5,Manufacturer 5,Batch No 5" ) CSV: Final[str] = ( "ORGANISATION_CODE,SCHOOL_URN,SCHOOL_NAME,CARE_SETTING,CLINIC_NAME,PERSON_FORENAME,PERSON_SURNAME,PERSON_DATE_OF_BIRTH,PERSON_DATE_OF_DEATH,YEAR_GROUP,PERSON_GENDER_CODE,PERSON_ADDRESS_LINE_1,PERSON_POSTCODE,NHS_NUMBER,NHS_NUMBER_STATUS_CODE,GP_ORGANISATION_CODE,GP_NAME,CONSENT_STATUS,CONSENT_DETAILS,HEALTH_QUESTION_ANSWERS,TRIAGE_STATUS,TRIAGED_BY,TRIAGE_DATE,TRIAGE_NOTES,GILLICK_STATUS,GILLICK_ASSESSMENT_DATE,GILLICK_ASSESSED_BY,GILLICK_ASSESSMENT_NOTES,GILLICK_NOTIFY_PARENTS,VACCINATED,DATE_OF_VACCINATION,TIME_OF_VACCINATION,PROGRAMME_NAME,VACCINE_GIVEN,PERFORMING_PROFESSIONAL_EMAIL,PERFORMING_PROFESSIONAL_FORENAME,PERFORMING_PROFESSIONAL_SURNAME,BATCH_NUMBER,BATCH_EXPIRY_DATE,ANATOMICAL_SITE,ROUTE_OF_VACCINATION,DOSE_SEQUENCE,REASON_NOT_VACCINATED,LOCAL_PATIENT_ID,SNOMED_PROCEDURE_CODE,REASON_FOR_INCLUSION,RECORD_CREATED,RECORD_UPDATED" diff --git a/libs/playwright_ops.py b/libs/playwright_ops.py index ac27e025b5b..5dfc06dc9b6 100644 --- a/libs/playwright_ops.py +++ b/libs/playwright_ops.py @@ -43,7 +43,7 @@ def capture_screenshot(self, identifier: str, action: str) -> None: ) self.ce.page.screenshot(path=_ss_path, type=screenshot_file_types.JPEG, full_page=True) - def verify(self, locator: str, property: str, expected_value: str, **kwargs) -> None: + def verify(self, locator: str, property: element_properties, expected_value: str, **kwargs) -> None: """ Verify a property of a web element. @@ -61,7 +61,7 @@ def verify(self, locator: str, property: str, expected_value: str, **kwargs) -> actual_value = self.get_element_property( locator=locator, property=property, by_test_id=by_test_id, chain_locator=chain_locator ) - match property.lower(): + match property: case element_properties.TEXT: if expected_value != "": self._verify_text( @@ -72,7 +72,7 @@ def verify(self, locator: str, property: str, expected_value: str, **kwargs) -> case element_properties.CHECKBOX_CHECKED: self._verify_checkbox(locator=locator, expected_value=expected_value, actual_value=actual_value) - def get_element_property(self, locator: str, property: str, **kwargs) -> str: + def get_element_property(self, locator: str, property: element_properties, **kwargs) -> str: """ Get a property of a web element. @@ -105,7 +105,7 @@ def get_element_property(self, locator: str, property: str, **kwargs) -> str: case element_properties.PAGE_URL: return self.ce.page.url - def act(self, locator, action, value=None, **kwargs) -> None: + def act(self, locator: str | None, action: framework_actions, value: str | None = None, **kwargs) -> None: """ Perform an action on a web element. @@ -115,11 +115,16 @@ def act(self, locator, action, value=None, **kwargs) -> None: value (str, optional): Value to use for the action. **kwargs: Additional options (e.g., exact match, index). """ + # Error check + if locator is None: + locator = "" + if value is None: + value = "" # Unpack keyword arguments exact: bool = kwargs.get("exact", False) index: int = kwargs.get("index", 0) # Act - match action.lower(): + match action: case framework_actions.CLICK_LINK: self._click_link(locator=locator, exact=exact, index=index) case framework_actions.CLICK_BUTTON: diff --git a/libs/testdata_ops.py b/libs/testdata_ops.py index aa605f3e0c6..936255f9baf 100644 --- a/libs/testdata_ops.py +++ b/libs/testdata_ops.py @@ -44,7 +44,6 @@ def create_file_from_template(self, template_path: str, file_name_prefix: str) - _ln = _ln.replace("<>", test_data_values.SCHOOL_2_NAME) _ln = _ln.replace("<>", test_data_values.SCHOOL_1_URN) _ln = _ln.replace("<>", test_data_values.ORG_CODE) - # _ln = _ln.replace("<>", f"9{self.get_new_nhs_no(valid=True)[:9]}") _ln = _ln.replace("<>", self.get_new_nhs_no(valid=True)) _ln = _ln.replace("<>", self.get_new_nhs_no(valid=False)) _ln = _ln.replace("<>", f"F{_dt}{_ctr}") @@ -76,7 +75,7 @@ def get_new_nhs_no(self, valid=True) -> str: """ return nhs_number.generate(valid=valid, for_region=nhs_number.REGION_ENGLAND, quantity=1)[0] - def get_expected_errors(self, file_path: str) -> list[str]: + def get_expected_errors(self, file_path: str): """ Get expected errors from a file. @@ -157,13 +156,13 @@ def create_child_list_from_file(self, file_path: str, file_type: str): match file_type: case mavis_file_types.CHILD_LIST | mavis_file_types.COHORT | mavis_file_types.CLASS_LIST: _child_list = _file_df[["CHILD_FIRST_NAME", "CHILD_LAST_NAME"]] - return _child_list["CHILD_LAST_NAME"] + " " + _child_list["CHILD_FIRST_NAME"].values.tolist() + return _child_list["CHILD_LAST_NAME"] + ", " + _child_list["CHILD_FIRST_NAME"].values.tolist() case mavis_file_types.VACCS_MAVIS: _child_list = _file_df[["PERSON_FORENAME", "PERSON_SURNAME"]] - return _child_list["PERSON_SURNAME"] + " " + _child_list["PERSON_FIRSTNAME"].values.tolist() + return _child_list["PERSON_SURNAME"] + ", " + _child_list["PERSON_FIRSTNAME"].values.tolist() case mavis_file_types.VACCS_SYSTMONE: _child_list = _file_df[["First name", "Surname"]] - return _child_list["Surname"] + " " + _child_list["First name"].values.tolist() + return _child_list["Surname"] + ", " + _child_list["First name"].values.tolist() case _: return None diff --git a/libs/wrappers.py b/libs/wrappers.py index e1ea56d7b66..d0903de43cc 100644 --- a/libs/wrappers.py +++ b/libs/wrappers.py @@ -146,7 +146,7 @@ def get_dob_from_year(year_group: str) -> str: # Generate a random date between start_date and end_date random_date = start_date + timedelta(days=random.randint(0, (end_date - start_date).days)) - return random_date.strftime("%Y%m%d") + return random_date.strftime("%Y-%m-%d") def get_project_root() -> str: @@ -190,7 +190,7 @@ def get_base64_decoded_string(encoded_string: str) -> str: return base64.b64decode(base64_bytes).decode(file_encoding.ASCII) -def run_shell_command(command: str) -> str: +def run_shell_command(command: str): """ Execute a shell command. diff --git a/pages/pg_children.py b/pages/pg_children.py index 57b366c327d..2a9d77110cc 100644 --- a/pages/pg_children.py +++ b/pages/pg_children.py @@ -44,7 +44,7 @@ def verify_filter(self): self.po.act(locator=None, action=framework_actions.WAIT, value=wait_time.MIN) self.po.verify(locator=self.LBL_MAIN, property=element_properties.TEXT, expected_value=self.LBL_CHILD_RECORD) - def verify_child_has_been_uploaded(self, child_list: list[str]) -> None: + def verify_child_has_been_uploaded(self, child_list) -> None: if len(child_list) >= 1: self.dashboard_page.go_to_dashboard() self.dashboard_page.click_children() diff --git a/pages/pg_import_records.py b/pages/pg_import_records.py index c0823acabfa..99e3e084abf 100644 --- a/pages/pg_import_records.py +++ b/pages/pg_import_records.py @@ -39,15 +39,14 @@ class pg_import_records: def __init__(self): self.upload_time = "" - def click_import_records(self): - self.po.act(locator=self.LNK_IMPORT_RECORDS, action=framework_actions.CLICK_LINK) - def import_child_records(self, file_paths: str, verify_on_children_page: bool = False): _input_file_path, _output_file_path = self.tdo.get_file_paths(file_paths=file_paths) + _cl = [] if verify_on_children_page: _cl = self.tdo.create_child_list_from_file( file_path=_input_file_path, file_type=mavis_file_types.CHILD_LIST ) + self.po.act(locator=self.LNK_IMPORT_RECORDS, action=framework_actions.CLICK_LINK) self.po.act(locator=self.RDO_CHILD_RECORDS, action=framework_actions.RADIO_BUTTON_SELECT) self.po.act(locator=self.BTN_CONTINUE, action=framework_actions.CLICK_BUTTON) self.po.act( @@ -64,8 +63,16 @@ def import_child_records(self, file_paths: str, verify_on_children_page: bool = if verify_on_children_page: self.children_page.verify_child_has_been_uploaded(child_list=_cl) - def import_class_list_records(self, file_paths: str, year_group: str = child_year_group.ALL): + def import_class_list_records( + self, file_paths: str, year_group: str = child_year_group.ALL, verify_on_children_page: bool = False + ): _input_file_path, _output_file_path = self.tdo.get_file_paths(file_paths=file_paths) + _cl = [] + if verify_on_children_page: + _cl = self.tdo.create_child_list_from_file( + file_path=_input_file_path, file_type=mavis_file_types.CHILD_LIST + ) + self.po.act(locator=self.LNK_IMPORT_RECORDS, action=framework_actions.CLICK_LINK) self.po.act(locator=self.RDO_CLASS_LIST_RECORDS, action=framework_actions.RADIO_BUTTON_SELECT) self.po.act(locator=self.BTN_CONTINUE, action=framework_actions.CLICK_BUTTON) self.po.act( @@ -86,6 +93,8 @@ def import_class_list_records(self, file_paths: str, year_group: str = child_yea if self.ce.get_file_record_count() > record_limit.FILE_RECORD_MAX_THRESHOLD: self._click_uploaded_file_datetime(truncated=True) self._verify_upload_output(file_path=_output_file_path) + if verify_on_children_page: + self.children_page.verify_child_has_been_uploaded(child_list=_cl) def import_class_list_records_from_school_session(self, file_paths: str): _input_file_path, _output_file_path = self.tdo.get_file_paths(file_paths=file_paths) @@ -105,6 +114,7 @@ def import_class_list_records_from_school_session(self, file_paths: str): def import_vaccination_records(self, file_paths: str): _input_file_path, _output_file_path = self.tdo.get_file_paths(file_paths=file_paths) + self.po.act(locator=self.LNK_IMPORT_RECORDS, action=framework_actions.CLICK_LINK) self.po.act(locator=self.RDO_VACCINATION_RECORDS, action=framework_actions.RADIO_BUTTON_SELECT) self.po.act(locator=self.BTN_CONTINUE, action=framework_actions.CLICK_BUTTON) self.po.act( diff --git a/pages/pg_vaccines.py b/pages/pg_vaccines.py index 322e4734406..d3d2aefe726 100644 --- a/pages/pg_vaccines.py +++ b/pages/pg_vaccines.py @@ -34,7 +34,7 @@ def verify_current_vaccine(self): exact=False, ) - def _calculate_batch_details(self, vacc_name: str): + def _calculate_batch_details(self, vacc_name: tuple[str, int]): self.vacc_name = vacc_name[0] self.add_btn_index = vacc_name[1] self.batch_name = f"{self.vacc_name}{get_current_datetime()}" @@ -43,7 +43,7 @@ def _calculate_batch_details(self, vacc_name: str): self.month = self.future_expiry_date[4:6] self.year = self.future_expiry_date[:4] - def add_batch(self, vaccine_name: str): + def add_batch(self, vaccine_name: tuple[str, int]): self._calculate_batch_details(vacc_name=vaccine_name) self.po.verify(locator=self.LBL_MAIN, property=element_properties.TEXT, expected_value=self.vacc_name) self.po.act(locator=self.LNK_ADD_NEW_BATCH, action=framework_actions.CLICK_LINK, index=self.add_btn_index) diff --git a/test_data/child/i_mav_1080.csv b/test_data/child/i_mav_1080.csv index d8a89a9fcc6..b8728d30226 100644 --- a/test_data/child/i_mav_1080.csv +++ b/test_data/child/i_mav_1080.csv @@ -1,5 +1,6 @@ -TEST_DESC_IGNORED,CHILD_FIRST_NAME,CHILD_LAST_NAME,CHILD_SCHOOL_URN,CHILD_DATE_OF_BIRTH,CHILD_NHS_NUMBER,CHILD_GENDER,CHILD_ADDRESS_LINE_1,CHILD_ADDRESS_LINE_2,CHILD_TOWN,CHILD_POSTCODE,CHILD_REGISTRATION,PARENT_1_NAME,PARENT_1_RELATIONSHIP,PARENT_1_EMAIL,PARENT_1_PHONE,PARENT_2_NAME,PARENT_2_RELATIONSHIP,PARENT_2_EMAIL,PARENT_2_PHONE,CHILD_YEAR_GROUP -TwoSpaces,C<> , C<> , <> , 2010-01-01 , <> , Male , Addr1 , Addr2 , Town , AA1 1AA , 8T5 , Parent1 , Dad , dad@example.com , , Parent2 , Mum , mum@example.com , , 9 -Tabs,C<> , C<> , 888888 , 20110101 , <> , Male , Addr1 , Addr2 , Town , AA1 1AA , 8T5 , Parent1 , Dad , dad@example.com , , Parent2 , Mum , mum@example.com , , 9 -SingleSpace,C<> , C<> , 999999 , 20100101 , <> , Male , Addr1 , Addr2 , Town , AA1 1AA , 8T5 , Parent1 , Dad , dad@example.com , , Parent2 , Mum , mum@example.com , , 9 -LeadingSpaces, C <>,C<>,<>,20100101,<>,Male,Addr1,Addr2,Town,AA11AA,8T5,Parent1,Dad,dad@example.com,,Parent2,Mum,mum@example.com,, +TEST_DESC_IGNORED,CHILD_FIRST_NAME,CHILD_LAST_NAME,CHILD_SCHOOL_URN,CHILD_DATE_OF_BIRTH,CHILD_NHS_NUMBER,CHILD_GENDER,CHILD_ADDRESS_LINE_1,CHILD_ADDRESS_LINE_2,CHILD_TOWN,CHILD_POSTCODE,CHILD_REGISTRATION,PARENT_1_NAME,PARENT_1_RELATIONSHIP,PARENT_1_EMAIL,PARENT_1_PHONE,PARENT_2_NAME,PARENT_2_RELATIONSHIP,PARENT_2_EMAIL,PARENT_2_PHONE,CHILD_YEAR_GROUP +TwoSpaces, C<> , C<> , <> , 2010-01-01 , <> , Male , Addr1 , Addr2 , Town , AA1 1AA , 8T5 , Parent1 , Dad , dad@example.com , , Parent2 , Mum , mum@example.com , , 9 +Tabs, C<> , C<> , 888888 , 20110101 , <> , Male , Addr1 , Addr2 , Town , AA1 1AA , 8T5 , Parent1 , Dad , dad@example.com , , Parent2 , Mum , mum@example.com , , 9 +NBSP,C<>,C<>,999999, 20100101,<>,Male,Addr1,Addr2,Town,AA1 1AA,8T5,Pa rent1,Dad,dad@example.com,,Parent2,Mum,mum@example.com,,9 +ZWJ,C<>,C<>,<>,20100101,<>,Male,Addr1,Addr2,Town,AA11AA,8T5,‍Parent1,Dad,dad@example.com,,Parent2,Mum,mum@example.com,, + diff --git a/test_data/child/i_negative.csv b/test_data/child/i_negative.csv index aa0f2cc09ac..8d954eee4c5 100644 --- a/test_data/child/i_negative.csv +++ b/test_data/child/i_negative.csv @@ -9,3 +9,4 @@ C<>,C<>,<>,20100101,<>,Male,Addr1,Addr2,Town C<>,C<>,<>,20100101,<>,Male,Addr1,Addr2,Town,AA1 1AA,8T5,Parent1,Dad,example.com,,Parent2,Mum,mum@example.com,,9 C<>,C<>,<>,20100101,<>,Male,Addr1,Addr2,Town,AA1 1AA,8T5,Parent1,Dad,dad@example.com,,Parent2,Mum,example.com,,9 C<>,C<>,<>,20100101,<>,Male,Addr1,Addr2,Town,AA1 1AA,8T5,Parent1,Dad,dad@example.com,,Parent2,Mum,mum@example.com,,19 +C<>,C<>,<>,2010010‍‍ ‍1,<>,Male,Addr1,Addr2,Town,AA1 1AA,8T5,Parent1,Dad,dad@example.com,,Parent2,Mum,mum@example.com,,9 diff --git a/test_data/child/o_negative.csv b/test_data/child/o_negative.csv index 62dae8fbd67..d8f0c3ff51b 100644 --- a/test_data/child/o_negative.csv +++ b/test_data/child/o_negative.csv @@ -14,3 +14,4 @@ Row 9 PARENT_1_EMAIL: should be a valid email address, like j.doe@example.com #Row 10 PARENT_2_EMAIL: ‘example.com’ should be a valid email address, like j.doe@example.com Row 10 PARENT_2_EMAIL: should be a valid email address, like j.doe@example.com Row 11 CHILD_YEAR_GROUP: is not part of this programme +Row 12 CHILD_DATE_OF_BIRTH: should be formatted as YYYY-MM-DD diff --git a/test_data/class_list/i_mav_1080.csv b/test_data/class_list/i_mav_1080.csv new file mode 100644 index 00000000000..fa91a0a9572 --- /dev/null +++ b/test_data/class_list/i_mav_1080.csv @@ -0,0 +1,5 @@ +TEST_DESC_IGNORED,CHILD_FIRST_NAME,CHILD_LAST_NAME,CHILD_PREFERRED_FIRST_NAME,CHILD_PREFERRED_LAST_NAME,CHILD_DATE_OF_BIRTH,CHILD_NHS_NUMBER,CHILD_GENDER,CHILD_ADDRESS_LINE_1,CHILD_ADDRESS_LINE_2,CHILD_TOWN,CHILD_REGISTRATION,CHILD_POSTCODE,PARENT_1_NAME,PARENT_1_RELATIONSHIP,PARENT_1_EMAIL,PARENT_1_PHONE,PARENT_2_NAME,PARENT_2_RELATIONSHIP,PARENT_2_EMAIL,PARENT_2_PHONE,CHILD_YEAR_GROUP +TwoSpace, C<> , C<> , PrefFirst1 , PrefLast1 , <> , <> , Male , Addr1 , Addr2 , Town , 8T5 , AA1 1AA , Parent1 , Dad , dad@example.com , , Parent2 , Mum , mum@example.com , , 9 +Tabs, C<> , C<> , PrefFirst1 , PrefLast1 , <> , <> , Male , Addr1 , Addr2 , Town , 8T5 , AA1 1AA , Parent1 , Dad , dad@example.com , , Parent2 , Mum , mum@example.com , , 9 +NBSP,C<>,C<>,PrefFirst1,PrefLast1,<>,<>,Male,Addr1,Addr2,Town,8T5,AA1 1AA,Pa rent1,Dad,dad@example.com,,Parent2,Mum,mum@example.com,,9 +ZWJ,C<>,C<>,PrefFirst1,PrefLast1,<>,<>,Male,Addr1,Addr2,Town,8T5,AA1 1AA,‍Parent1,Dad,dad@example.com,,Parent2,Mum,mum@example.com,,9 diff --git a/test_data/class_list/o_mav_1080.csv b/test_data/class_list/o_mav_1080.csv new file mode 100644 index 00000000000..f426d37f640 --- /dev/null +++ b/test_data/class_list/o_mav_1080.csv @@ -0,0 +1 @@ +4 children diff --git a/test_data/file_mapping.csv b/test_data/file_mapping.csv index c552b1e608c..a7be3230cce 100644 --- a/test_data/file_mapping.csv +++ b/test_data/file_mapping.csv @@ -11,9 +11,11 @@ VACCS_HPV_HEADER_ONLY,test_data/vaccs/i_header_only.csv,test_data/vaccs/o_header VACCS_HPV_MAV_853,test_data/vaccs/i_mav_853.csv,test_data/vaccs/o_mav_853.csv,hpvmav853 VACCS_HPV_MAV_855,test_data/vaccs/i_mav_855.csv,test_data/vaccs/o_mav_855.csv,hpvmav855 VACCS_HPV_DOSE_TWO,test_data/vaccs/i_dose_two.csv,test_data/vaccs/o_dose_two.csv,hpvdose2 +VACCS_MAV_1080,test_data/vaccs/i_mav_1080.csv,test_data/vaccs/o_mav_1080.csv,hpvmav1080 VACCS_SYSTMONE_POSITIVE,test_data/vaccs/i_systmone_positive.csv,test_data/vaccs/o_systmone_positive.csv,systmonepos VACCS_SYSTMONE_NEGATIVE,test_data/vaccs/i_systmone_negative.csv,test_data/vaccs/o_systmone_negative.csv,systmoneneg VACCS_SYSTMONE_HIST_NEGATIVE,test_data/vaccs/i_systmone_hist_negative.csv,test_data/vaccs/o_systmone_hist_negative.csv,systmonehistneg +VACCS_SYSTMONE_MAV_1080,test_data/vaccs/i_systmone_mav_1080.csv,test_data/vaccs/o_systmone_mav_1080.csv,systmonemav1080 COHORTS_POSITIVE,test_data/cohorts/i_positive.csv,test_data/cohorts/o_positive.csv,cohortpos COHORTS_NEGATIVE,test_data/cohorts/i_negative.csv,test_data/cohorts/o_negative.csv,cohortneg COHORTS_INVALID_STRUCTURE,test_data/cohorts/i_invalid_structure.csv,test_data/cohorts/o_invalid_structure.csv,cohortstruc @@ -37,6 +39,7 @@ CLASS_SESSION_ID,test_data/class_list/i_session_id.csv,test_data/class_list/o_se CLASS_SINGLE_VACC,test_data/class_list/i_single_vacc.csv,test_data/class_list/o_single_vacc.csv,classsinglevacc CLASS_MAV_965,test_data/class_list/i_mav_965.csv,test_data/class_list/o_mav_965.csv,classmav965 CLASS_CHANGE_NHSNO,test_data/class_list/i_change_nhsno.csv,test_data/class_list/o_change_nhsno.csv,classchangenhsno +CLASS_MAV_1080,test_data/class_list/i_mav_1080.csv,test_data/class_list/o_mav_1080.csv,classmav1080 COHORTS_NO_CONSENT,test_data/cohorts/i_no_consent.csv,test_data/cohorts/o_no_consent.csv,cohortnoconsent COHORTS_CONFLICTING_CONSENT,test_data/cohorts/i_conflicting_consent.csv,test_data/cohorts/o_conflicting_consent.csv,cohortconflict COHORTS_E2E_1,test_data/cohorts/i_e2e_1.csv,test_data/cohorts/o_e2e_1.csv,cohort_e2e diff --git a/test_data/vaccs/i_mav_1080.csv b/test_data/vaccs/i_mav_1080.csv new file mode 100644 index 00000000000..27f31413c86 --- /dev/null +++ b/test_data/vaccs/i_mav_1080.csv @@ -0,0 +1,5 @@ +TEST_DESC_IGNORED,ORGANISATION_CODE,SCHOOL_URN,SCHOOL_NAME,NHS_NUMBER,PERSON_FORENAME,PERSON_SURNAME,PERSON_DOB,PERSON_GENDER_CODE,PERSON_POSTCODE,DATE_OF_VACCINATION,VACCINE_GIVEN,BATCH_NUMBER,BATCH_EXPIRY_DATE,ANATOMICAL_SITE,DOSE_SEQUENCE,VACCINATED,CARE_SETTING,PERFORMING_PROFESSIONAL_FORENAME,PERFORMING_PROFESSIONAL_SURNAME,PERFORMING_PROFESSIONAL_EMAIL,CLINIC_NAME,TIME_OF_VACCINATION,REASON_NOT_VACCINATED,SESSION_ID,PROGRAMME +TwoSpaces,<> , <> , <> , <> , <> , <> , <> , Male , DN9 1PB , <> , Gardasil9 , AutoBatch1 , 20301231 , Left Thigh , 1 , Y , 1 , , , nurse.joy@example.com , Clinic , 00:01 , , <> , HPV +Tabs,<> , <> , <> , <> , <> , <> , <> , Male , DN9 1PB , <> , Gardasil , AutoBatch1 , 20301231 , Right Thigh , 2 , Y , 1 , , , nurse.joy@example.com , Clinic , 00:01 , , <> , HPV +NBSP,<>,<>,<>,<>,<>,<>,<>,Male,DN9 1PB,<>,Cer varix,AutoBatch1,20301231,left upper arm,3,Y,1,,,nurse.joy@example.com,Clinic,00:01,,<>,HPV +ZWJ,<>,<>,<>,<>,<>,<>,<>,Male,ZZ99 3VZ,<>,Gard‍asil9,AutoBatch1,20301231,left arm (upper position),1,Y,1,,,nurse.joy@example.com,Clinic,00:01,,<>,HPV diff --git a/test_data/vaccs/i_systmone_mav_1080.csv b/test_data/vaccs/i_systmone_mav_1080.csv new file mode 100644 index 00000000000..fd8d64e66d4 --- /dev/null +++ b/test_data/vaccs/i_systmone_mav_1080.csv @@ -0,0 +1,9 @@ +TEST_DESC_IGNORED,Date of birth,NHS number,Vaccination area code,Vaccination batch number,Vaccination reason,Vaccination type,First name,Postcode,Sex,Surname,Event date,Event location type,Event time,Organisation ID,School,School code,Patient Count +TwoSpaces, <> , <> , , 123013325 , , Cervarix 1 , C<> , LE3 2DA , Female , C<> , <> , School , <> , <> , <> , <> , +Tabs,<> , <> , , 123013325 , , Gardasil9 1 , C<> , LE3 2DA , Female , C<> , <> , School , <> , <> , <> , <> , +NBSP,<>,<>,,123013325,,Gard asil9 1,C<>,LE3 2DA,Female,C<>,<>,School,<>,<>,<>,<>, +ZWJ,<>,<>,,123013325,,Gar‍dasil9 1,C<>,LE3 2DA,Female,C<>,<>,School,<>,<>,<>,<>, +HistoricalTwoSpaces, <> , <> , , 123013325 , , Cervarix 1 , C<> , LE3 2DA , Female , C<> , <> , School , <> , <> , <> , <> , +HistoricalTabs,<> , <> , , 123013325 , , Gardasil9 1 , C<> , LE3 2DA , Female , C<> , <> , School , <> , <> , <> , <> , +HistoricalNBSP,<>,<>,,123013325,,Gard asil9 1,C<>,LE3 2DA,Female,C<>,<>,School,<>,<>,<>,<>, +HistoricalZWJ,<>,<>,,123013325,,Gar‍dasil9 1,C<>,LE3 2DA,Female,C<>,<>,School,<>,<>,<>,<>, diff --git a/test_data/vaccs/o_mav_1080.csv b/test_data/vaccs/o_mav_1080.csv new file mode 100644 index 00000000000..234f2403eec --- /dev/null +++ b/test_data/vaccs/o_mav_1080.csv @@ -0,0 +1 @@ +4 vaccination records diff --git a/test_data/vaccs/o_systmone_mav_1080.csv b/test_data/vaccs/o_systmone_mav_1080.csv new file mode 100644 index 00000000000..291aed9bbf8 --- /dev/null +++ b/test_data/vaccs/o_systmone_mav_1080.csv @@ -0,0 +1 @@ +8 vaccination records diff --git a/tests/test_01_login.py b/tests/test_01_login.py index 92849d97b42..8c92bdee6b2 100644 --- a/tests/test_01_login.py +++ b/tests/test_01_login.py @@ -1,6 +1,5 @@ import pytest -from libs.generic_constants import fixture_scope from pages import pg_dashboard, pg_login @@ -8,7 +7,7 @@ class Test_Login: login_page = pg_login.pg_login() dashboard_page = pg_dashboard.pg_dashboard() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=True) + @pytest.fixture(scope="function", autouse=True) def setup_tests(self, start_mavis: None): yield diff --git a/tests/test_02_sessions.py b/tests/test_02_sessions.py index 4f7393551fd..c9acf648f87 100644 --- a/tests/test_02_sessions.py +++ b/tests/test_02_sessions.py @@ -1,6 +1,5 @@ import pytest -from libs.generic_constants import fixture_scope from libs.mavis_constants import test_data_file_paths from pages import pg_dashboard, pg_login, pg_sessions @@ -10,7 +9,7 @@ class Test_Sessions: dashboard_page = pg_dashboard.pg_dashboard() sessions_page = pg_sessions.pg_sessions() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_tests(self, start_mavis: None): self.login_page.login_as_nurse() self.dashboard_page.go_to_dashboard() @@ -18,7 +17,7 @@ def setup_tests(self, start_mavis: None): yield self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_mavis_1822(self, start_mavis: None): try: self.login_page.login_as_nurse() @@ -39,7 +38,7 @@ def setup_mavis_1822(self, start_mavis: None): self.sessions_page.delete_all_sessions_for_school_1() self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_mav_1018(self, start_mavis: None): try: self.login_page.login_as_nurse() diff --git a/tests/test_03_import_records.py b/tests/test_03_import_records.py index 0cb43b88fc1..d29a517a571 100644 --- a/tests/test_03_import_records.py +++ b/tests/test_03_import_records.py @@ -1,8 +1,7 @@ import pytest -from libs.generic_constants import fixture_scope from libs.mavis_constants import child_year_group, test_data_file_paths -from pages import pg_children, pg_dashboard, pg_import_records, pg_login, pg_sessions +from pages import pg_dashboard, pg_import_records, pg_login, pg_sessions class Test_ImportRecords: @@ -11,33 +10,31 @@ class Test_ImportRecords: import_records_page = pg_import_records.pg_import_records() sessions_page = pg_sessions.pg_sessions() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_tests(self, start_mavis: None): self.login_page.login_as_nurse() yield self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_child_list(self, setup_tests: None): self.dashboard_page.click_import_records() - self.import_records_page.click_import_records() yield - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_class_list(self, setup_tests: None): try: self.dashboard_page.click_sessions() self.sessions_page.schedule_a_valid_session_in_school_1() self.dashboard_page.go_to_dashboard() self.dashboard_page.click_import_records() - self.import_records_page.click_import_records() yield finally: self.dashboard_page.go_to_dashboard() self.dashboard_page.click_sessions() self.sessions_page.delete_all_sessions_for_school_1() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_vaccs(self, setup_tests: None): try: self.dashboard_page.click_sessions() @@ -49,21 +46,19 @@ def setup_vaccs(self, setup_tests: None): self.sessions_page.save_session_id_from_offline_excel() self.dashboard_page.go_to_dashboard() self.dashboard_page.click_import_records() - self.import_records_page.click_import_records() yield finally: self.dashboard_page.go_to_dashboard() self.dashboard_page.click_sessions() self.sessions_page.delete_all_sessions_for_school_1() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_vaccs_systmone(self, setup_tests: None): try: self.dashboard_page.click_sessions() self.sessions_page.schedule_a_valid_session_in_school_1(for_today=True) self.dashboard_page.go_to_dashboard() self.dashboard_page.click_import_records() - self.import_records_page.click_import_records() yield finally: self.dashboard_page.go_to_dashboard() @@ -98,7 +93,6 @@ def test_child_list_empty_file(self, setup_child_list): @pytest.mark.childlist @pytest.mark.order(306) - @pytest.mark.skip(reason="Test under construction") def test_child_list_space_normalisation(self, setup_child_list): self.import_records_page.import_child_records( file_paths=test_data_file_paths.CHILD_MAV_1080, verify_on_children_page=True @@ -138,6 +132,13 @@ def test_class_list_year_group(self, setup_class_list: None): file_paths=test_data_file_paths.CLASS_YEAR_GROUP, year_group=child_year_group.YEAR_8 ) + @pytest.mark.classlist + @pytest.mark.order(332) + def test_class_list_space_normalization(self, setup_class_list: None): + self.import_records_page.import_class_list_records( + file_paths=test_data_file_paths.CLASS_MAV_1080, verify_on_children_page=True + ) + ########################################### VACCINATIONS ########################################### @pytest.mark.vaccinations @@ -156,7 +157,6 @@ def test_vaccs_duplicate_record_upload(self, setup_vaccs): self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_DUP_1) self.dashboard_page.go_to_dashboard() self.dashboard_page.click_import_records() - self.import_records_page.click_import_records() self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_DUP_2) @pytest.mark.vaccinations @@ -208,3 +208,13 @@ def test_vaccs_systmone_negative_historical_file_upload(self, setup_vaccs_systmo self.import_records_page.import_vaccination_records( file_paths=test_data_file_paths.VACCS_SYSTMONE_HIST_NEGATIVE ) + + @pytest.mark.vaccinations + @pytest.mark.order(363) + def test_vaccs_hpv_space_normalization(self, setup_vaccs): + self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_MAV_1080) + + @pytest.mark.vaccinations + @pytest.mark.order(364) + def test_vaccs_systmone_space_normalization(self, setup_vaccs_systmone): + self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_SYSTMONE_POSITIVE) diff --git a/tests/test_04_school_moves.py b/tests/test_04_school_moves.py index a3fd7256cfa..94d9faf2474 100644 --- a/tests/test_04_school_moves.py +++ b/tests/test_04_school_moves.py @@ -1,7 +1,6 @@ import pytest from libs import CurrentExecution -from libs.generic_constants import fixture_scope from libs.mavis_constants import test_data_file_paths from pages import pg_dashboard, pg_login, pg_school_moves, pg_sessions @@ -13,14 +12,14 @@ class Test_School_Moves: school_moves_page = pg_school_moves.pg_school_moves() ce = CurrentExecution() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_tests(self, start_mavis: None): self.ce.reset_environment() self.login_page.login_as_nurse() yield self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_move_and_ignore(self, setup_tests: None): try: self.dashboard_page.click_sessions() @@ -51,7 +50,7 @@ def setup_move_and_ignore(self, setup_tests: None): self.dashboard_page.click_sessions() self.sessions_page.delete_all_sessions_for_school_2() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_move_to_homeschool_and_unknown(self, setup_tests: None): try: self.dashboard_page.click_sessions() diff --git a/tests/test_05_programmes.py b/tests/test_05_programmes.py index 0f1e8c61c94..275ae1d7af9 100644 --- a/tests/test_05_programmes.py +++ b/tests/test_05_programmes.py @@ -1,6 +1,5 @@ import pytest -from libs.generic_constants import fixture_scope from libs.mavis_constants import programmes, test_data_file_paths, vaccines from pages import ( pg_dashboard, @@ -20,14 +19,14 @@ class Test_Programmes: import_records_page = pg_import_records.pg_import_records() vaccines_page = pg_vaccines.pg_vaccines() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_cohort_upload_and_reports(self, start_mavis: None): self.login_page.login_as_nurse() self.dashboard_page.click_programmes() yield self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_record_a_vaccine(self, start_mavis: None): try: self.login_page.login_as_nurse() @@ -42,7 +41,7 @@ def setup_record_a_vaccine(self, start_mavis: None): self.sessions_page.delete_all_sessions_for_school_1() self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_mavis_1729(self, start_mavis: None): try: self.login_page.login_as_nurse() @@ -55,7 +54,6 @@ def setup_mavis_1729(self, start_mavis: None): self.sessions_page.save_session_id_from_offline_excel() self.dashboard_page.go_to_dashboard() self.dashboard_page.click_import_records() - self.import_records_page.click_import_records() self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_HPV_DOSE_TWO) self.dashboard_page.go_to_dashboard() self.dashboard_page.click_programmes() @@ -66,7 +64,7 @@ def setup_mavis_1729(self, start_mavis: None): self.sessions_page.delete_all_sessions_for_school_1() self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_mav_854(self, start_mavis: None): try: self.login_page.login_as_nurse() @@ -92,7 +90,7 @@ def setup_mav_854(self, start_mavis: None): self.sessions_page.delete_all_sessions_for_school_1() self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_mav_nnn(self, start_mavis: None): try: self.login_page.login_as_admin() @@ -165,7 +163,8 @@ def test_programmes_rav_verify_excel_mav_854(self, setup_mav_854): @pytest.mark.order(530) @pytest.mark.skip(reason="Test under construction") def test_programmes_rav_verify_banners(self, setup_mav_nnn): - self.programmes_page.verify_mav_nnn() + # self.programmes_page.verify_mav_nnn() + pass @pytest.mark.reports @pytest.mark.order(551) diff --git a/tests/test_06_vaccs_batch.py b/tests/test_06_vaccs_batch.py index 96bf17b6506..54b879b0f5f 100644 --- a/tests/test_06_vaccs_batch.py +++ b/tests/test_06_vaccs_batch.py @@ -1,6 +1,5 @@ import pytest -from libs.generic_constants import fixture_scope from libs.mavis_constants import vaccines from pages import pg_dashboard, pg_login, pg_vaccines @@ -11,7 +10,7 @@ class Test_Regression_Vaccines: vaccines_page = pg_vaccines.pg_vaccines() doubles_vaccines = [vaccines.MENQUADFI, vaccines.MENVEO, vaccines.NIMENRIX, vaccines.REVAXIS] - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=True) + @pytest.fixture(scope="function", autouse=True) def setup_tests(self, start_mavis: None): self.login_page.login_as_nurse() self.dashboard_page.click_vaccines() diff --git a/tests/test_07_children.py b/tests/test_07_children.py index 303e7af411a..f5b4328393e 100644 --- a/tests/test_07_children.py +++ b/tests/test_07_children.py @@ -1,6 +1,5 @@ import pytest -from libs.generic_constants import fixture_scope from libs.mavis_constants import test_data_file_paths from pages import ( pg_children, @@ -20,13 +19,13 @@ class Test_Children: import_records_page = pg_import_records.pg_import_records() programmes_page = pg_programmes.pg_programmes() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_tests(self, start_mavis: None): self.login_page.login_as_nurse() yield self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_children_page(self, setup_tests: None): try: self.dashboard_page.click_sessions() @@ -43,7 +42,7 @@ def setup_children_page(self, setup_tests: None): self.dashboard_page.click_sessions() self.sessions_page.delete_all_sessions_for_school_1() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_change_nhsno(self, setup_tests: None): try: self.dashboard_page.click_sessions() @@ -60,7 +59,7 @@ def setup_change_nhsno(self, setup_tests: None): self.dashboard_page.click_sessions() self.sessions_page.delete_all_sessions_for_school_1() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_mav_853(self, setup_tests: None): try: self.dashboard_page.click_sessions() @@ -75,7 +74,6 @@ def setup_mav_853(self, setup_tests: None): self.programmes_page.upload_cohorts(file_paths=test_data_file_paths.COHORTS_MAV_853) self.dashboard_page.go_to_dashboard() self.dashboard_page.click_import_records() - self.import_records_page.click_import_records() self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_MAV_853) self.dashboard_page.go_to_dashboard() self.dashboard_page.click_children() diff --git a/tests/test_08_consent_doubles.py b/tests/test_08_consent_doubles.py index d0445f38552..7e54d17ced7 100644 --- a/tests/test_08_consent_doubles.py +++ b/tests/test_08_consent_doubles.py @@ -4,7 +4,6 @@ from pandas.core.series import Series from libs import CurrentExecution, playwright_ops -from libs.generic_constants import fixture_scope from pages import pg_consent_hpv, pg_dashboard, pg_login, pg_sessions from tests.helpers import parental_consent_helper_doubles @@ -18,7 +17,7 @@ class Test_Consent_Doubles: dashboard_page = pg_dashboard.pg_dashboard() sessions_page = pg_sessions.pg_sessions() - @pytest.fixture(scope=fixture_scope.FUNCTION) + @pytest.fixture(scope="function") def get_doubles_session_link(self, start_mavis: None): try: self.login_page.login_as_nurse() diff --git a/tests/test_09_consent_hpv.py b/tests/test_09_consent_hpv.py index 09ddb92487c..7f6e7f994c5 100644 --- a/tests/test_09_consent_hpv.py +++ b/tests/test_09_consent_hpv.py @@ -4,7 +4,6 @@ from pandas.core.series import Series from libs import CurrentExecution, playwright_ops -from libs.generic_constants import fixture_scope from libs.mavis_constants import test_data_file_paths from pages import pg_consent_hpv, pg_dashboard, pg_login, pg_sessions from tests.helpers import parental_consent_helper_hpv @@ -19,7 +18,7 @@ class Test_Consent_HPV: dashboard_page = pg_dashboard.pg_dashboard() sessions_page = pg_sessions.pg_sessions() - @pytest.fixture(scope=fixture_scope.FUNCTION) + @pytest.fixture(scope="function") def get_hpv_session_link(self, start_mavis: None): try: self.login_page.login_as_nurse() @@ -35,7 +34,7 @@ def get_hpv_session_link(self, start_mavis: None): self.sessions_page.delete_all_sessions_for_school_1() self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_gillick(self, start_mavis: None): try: self.login_page.login_as_nurse() @@ -54,7 +53,7 @@ def setup_gillick(self, start_mavis: None): self.sessions_page.delete_all_sessions_for_school_1() self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_invalidated_consent(self, start_mavis: None): try: self.login_page.login_as_nurse() @@ -76,7 +75,7 @@ def setup_invalidated_consent(self, start_mavis: None): self.sessions_page.delete_all_sessions_for_school_1() self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_mavis_1696(self, start_mavis: None): try: self.login_page.login_as_nurse() @@ -100,7 +99,7 @@ def setup_mavis_1696(self, start_mavis: None): self.sessions_page.delete_all_sessions_for_school_1() self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_mavis_1864(self, start_mavis: None): try: self.login_page.login_as_nurse() @@ -122,7 +121,7 @@ def setup_mavis_1864(self, start_mavis: None): self.sessions_page.delete_all_sessions_for_school_1() self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_mavis_1818(self, start_mavis: None): try: self.login_page.login_as_nurse() diff --git a/tests/test_10_unmatched_consent_responses.py b/tests/test_10_unmatched_consent_responses.py index fce84f45857..71618f0a039 100644 --- a/tests/test_10_unmatched_consent_responses.py +++ b/tests/test_10_unmatched_consent_responses.py @@ -1,7 +1,6 @@ import pytest from libs import CurrentExecution -from libs.generic_constants import fixture_scope from libs.mavis_constants import test_data_file_paths from libs.wrappers import * from pages import pg_dashboard, pg_login, pg_programmes, pg_unmatched @@ -18,7 +17,7 @@ class Test_Unmatched_Consent_Responses: # RUN THE CONSENT WORKFLOW TESTS OR THE FULL PACK BEFORE RUNNING THESE TESTS # SET THE 'RESET_ENV_BEFORE_EXECUTION' FLAG (in .env) TO 'false' IF RUNNING ONLY CONSENT TESTS - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_tests(self, start_mavis: None): self.login_page.login_as_nurse() self.dashboard_page.go_to_dashboard() @@ -26,7 +25,7 @@ def setup_tests(self, start_mavis: None): yield self.login_page.logout_of_mavis() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_ucr_match(self, start_mavis: None): try: self.login_page.login_as_nurse() diff --git a/tests/test_50_e2e.py b/tests/test_50_e2e.py index c7fd2700c12..6d5f94c9749 100644 --- a/tests/test_50_e2e.py +++ b/tests/test_50_e2e.py @@ -1,7 +1,6 @@ import pytest from libs import CurrentExecution -from libs.generic_constants import fixture_scope from libs.mavis_constants import test_data_file_paths from pages import pg_dashboard, pg_login, pg_programmes, pg_sessions @@ -13,7 +12,7 @@ class Test_E2E: programmes_page = pg_programmes.pg_programmes() sessions_page = pg_sessions.pg_sessions() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=True) + @pytest.fixture(scope="function", autouse=True) def setup_tests(self, start_mavis: None): self.ce.reset_environment() self.login_page.login_as_nurse() diff --git a/tests/test_99_reset.py b/tests/test_99_reset.py index 39b117bd89c..c4c9660e928 100644 --- a/tests/test_99_reset.py +++ b/tests/test_99_reset.py @@ -1,7 +1,6 @@ import pytest from libs import CurrentExecution -from libs.generic_constants import fixture_scope from libs.mavis_constants import test_data_file_paths, vaccines from pages import ( pg_dashboard, @@ -22,7 +21,7 @@ class Test_Reset: vaccines_page = pg_vaccines.pg_vaccines() import_records_page = pg_import_records.pg_import_records() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_tests(self, start_mavis: None): self.ce.reset_environment() self.login_page.login_as_nurse() @@ -30,7 +29,7 @@ def setup_tests(self, start_mavis: None): self.login_page.logout_of_mavis() self.ce.reset_environment() - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_mav_965(self, setup_tests: None): self.dashboard_page.click_vaccines() self.vaccines_page.add_batch(vaccine_name=vaccines.GARDASIL9) # HPV @@ -46,7 +45,7 @@ def setup_mav_965(self, setup_tests: None): self.dashboard_page.click_sessions() yield - @pytest.fixture(scope=fixture_scope.FUNCTION, autouse=False) + @pytest.fixture(scope="function", autouse=False) def setup_cohort_upload_and_reports(self, setup_tests: None): self.dashboard_page.click_programmes() yield