Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,35 @@
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"cSpell.words": [
"careplus",
"childlist",
"CLAST",
"CONFLICTINGCONSENT",
"consentworkflow",
"dotenv",
"downcasting",
"exitstatus",
"fillna",
"GARDASIL",
"GARDASIL9",
"hookwrapper",
"HOYTE",
"MENACWY",
"NOCONSENT",
"nodeid",
"SAIS",
"schoolmoves",
"sessionfinish",
"sessionstart",
"SYSTM",
"SYSTMONE",
"TDIPV",
"tryfirst",
"trylast",
"unmatchedconsentresponses",
"venv",
"GARDASIL","GARDASIL9","VACC","vacc","careplus","MENACWY","TDIPV","SYSTMONE","SYSTM"
"vacc",
"VACC",
"venv"
],
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
Expand Down
2 changes: 2 additions & 0 deletions libs/generic_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class escape_characters:
PIPE: Final[str] = "|"
ASTERISK: Final[str] = "*"
QUESTION_MARK: Final[str] = "?"
COMMA: Final[str] = ","
UI_FORMATTING: Final[list[str]] = [
SPACE,
NEW_LINE,
Expand All @@ -114,6 +115,7 @@ class escape_characters:
SINGLE_QUOTE_CLOSE_UNICODE,
SINGLE_QUOTE_CLOSE,
TAB,
COMMA,
]
FILE_NAME: Final[list[str]] = [
SEPARATOR_CHAR,
Expand Down
9 changes: 9 additions & 0 deletions libs/mavis_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ class test_data_values:
EMPTY: Final[str] = "<empty>"


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 record_limit:
FILE_RECORD_MIN_THRESHOLD: Final[int] = 15
FILE_RECORD_MAX_THRESHOLD: Final[int] = 15
Expand Down Expand Up @@ -82,6 +90,7 @@ class test_data_file_paths:
CHILD_INVALID_STRUCTURE: Final[str] = "CHILD_INVALID_STRUCTURE"
CHILD_EMPTY_FILE: Final[str] = "CHILD_EMPTY_FILE"
CHILD_HEADER_ONLY: Final[str] = "CHILD_HEADER_ONLY"
CHILD_MAV_1080: Final[str] = "CHILD_MAV_1080"
CLASS_POSITIVE: Final[str] = "CLASS_POSITIVE"
CLASS_NEGATIVE: Final[str] = "CLASS_NEGATIVE"
CLASS_INVALID_STRUCTURE: Final[str] = "CLASS_INVALID_STRUCTURE"
Expand Down
23 changes: 15 additions & 8 deletions libs/testdata_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from libs import CurrentExecution, file_ops
from libs.generic_constants import escape_characters
from libs.mavis_constants import test_data_values
from libs.mavis_constants import mavis_file_types, test_data_values
from libs.wrappers import *


Expand Down Expand Up @@ -143,7 +143,7 @@ def get_file_paths(self, file_paths: str) -> tuple[str, str]:
)
return _input_file_path, _output_template_path

def create_child_list_from_file(self, file_path: str):
def create_child_list_from_file(self, file_path: str, file_type: str):
"""
Create a list of child names from a file.

Expand All @@ -153,12 +153,19 @@ def create_child_list_from_file(self, file_path: str):
Returns:
list: List of child names.
"""
if "positive" in file_path.lower():
_file_df = self.fo.read_csv_to_df(file_path=file_path)
_child_list = _file_df[["CHILD_FIRST_NAME", "CHILD_LAST_NAME"]]
return _child_list["CHILD_FIRST_NAME"] + " " + _child_list["CHILD_LAST_NAME"].values.tolist()
else:
return None
_file_df = self.fo.read_csv_to_df(file_path=file_path)
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()
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()
case mavis_file_types.VACCS_SYSTMONE:
_child_list = _file_df[["First name", "Surname"]]
return _child_list["Surname"] + " " + _child_list["First name"].values.tolist()
case _:
return None

def get_session_id(self, excel_path: str) -> str:
"""
Expand Down
11 changes: 6 additions & 5 deletions pages/pg_children.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ 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_exists(self) -> None:
if len(self.ce.child_list) >= 1:
def verify_child_has_been_uploaded(self, child_list: list[str]) -> None:
if len(child_list) >= 1:
self.dashboard_page.go_to_dashboard()
self.dashboard_page.click_children()
for child_name in self.ce.child_list:
self.search_for_a_child(child_name=child_name)
self.po.act(locator=self.LNK_CLEAR_FILTERS, action=framework_actions.CLICK_LINK)
for _child_name in child_list:
_cn = _child_name.strip()
self.search_for_a_child(child_name=_cn)
# self.po.act(locator=self.LNK_CLEAR_FILTERS, action=framework_actions.CLICK_LINK)

def search_for_a_child(self, child_name: str) -> None:
self.po.act(locator=self.TXT_SEARCH, action=framework_actions.FILL, value=child_name)
Expand Down
16 changes: 11 additions & 5 deletions pages/pg_import_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from libs import CurrentExecution, file_ops, playwright_ops, testdata_ops
from libs.generic_constants import element_properties, framework_actions, wait_time
from libs.mavis_constants import child_year_group, record_limit
from libs.mavis_constants import child_year_group, mavis_file_types, record_limit
from libs.wrappers import *
from pages import pg_children, pg_dashboard, pg_sessions, pg_vaccines

Expand All @@ -25,11 +25,8 @@ class pg_import_records:
RDO_VACCINATION_RECORDS: Final[str] = "Vaccination records"
BTN_CONTINUE: Final[str] = "Continue"
LBL_CHILD_RECORDS: Final[str] = "Upload file"
# LBL_CLASS_LIST_RECORDS: Final[str] = f"{sessions_page.LNK_SCHOOL_1}Import"
LBL_CLASS_LIST_RECORDS: Final[str] = "Upload file"
# LBL_VACCINATION_RECORDS: Final[str] = "Vaccination records"
LBL_VACCINATION_RECORDS: Final[str] = "Upload file"
# LBL_CLASS_LIST_RECORDS_FOR_SCHOOL1: Final[str] = f"{sessions_page.LNK_SCHOOL_1}Import"
LBL_CLASS_LIST_RECORDS_FOR_SCHOOL1: Final[str] = "Upload file"
LBL_SCHOOL_NAME: Final[str] = "Which school is this class"
LBL_MAIN: Final[str] = "main"
Expand All @@ -39,11 +36,18 @@ class pg_import_records:
CHK_YEAR11: Final[str] = "Year 11"
LNK_IMPORT_CLASS_LIST_RECORDS: Final[str] = "Import class lists"

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):
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)
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.RDO_CHILD_RECORDS, action=framework_actions.RADIO_BUTTON_SELECT)
self.po.act(locator=self.BTN_CONTINUE, action=framework_actions.CLICK_BUTTON)
self.po.act(
Expand All @@ -57,6 +61,8 @@ def import_child_records(self, file_paths: str):
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(self, file_paths: str, year_group: str = child_year_group.ALL):
_input_file_path, _output_file_path = self.tdo.get_file_paths(file_paths=file_paths)
Expand Down
14 changes: 5 additions & 9 deletions pages/pg_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class pg_sessions:
LNK_TAB_ACTIVITY_LOG: Final[str] = "Activity log"
LNK_TAB_REGISTER: Final[str] = "Register"
LNK_IMPORT_CLASS_LIST: Final[str] = "Import class lists"
# LBL_CHOOSE_COHORT_FILE_1: str = f"{LNK_SCHOOL_1}Import class"
# LBL_CHOOSE_COHORT_FILE_2: str = f"{LNK_SCHOOL_2}Import class"
LBL_CHOOSE_COHORT_FILE_1: str = "Upload file"
LBL_CHOOSE_COHORT_FILE_2: str = "Upload file"
BTN_CONTINUE: Final[str] = "Continue"
Expand Down Expand Up @@ -130,7 +128,7 @@ def __get_display_formatted_date(self, date_to_format: str) -> str:
_formatted_date = _parsed_date.strftime("%A %d %B %Y").replace(" 0", " ")
return _formatted_date

def __record_upload_time(self):
def _record_upload_time(self):
self.upload_time = get_link_formatted_date_time()

def click_uploaded_file_datetime(self):
Expand Down Expand Up @@ -607,14 +605,13 @@ def upload_class_list_to_school_1(
self.select_year_group(year_group=year_group)
self.choose_file_child_records_for_school_1(file_path=_input_file_path)
self.click_continue()
self.__record_upload_time()
self._record_upload_time()
if self.ce.get_file_record_count() > record_limit.FILE_RECORD_MIN_THRESHOLD:
self.po.act(locator=None, action=framework_actions.WAIT, value=wait_time.MED)
if self.ce.get_file_record_count() > record_limit.FILE_RECORD_MAX_THRESHOLD:
self.click_uploaded_file_datetime()
self.verify_upload_output(file_path=_output_file_path)
if verify_on_children:
self.children_page.verify_child_exists()
self.children_page.verify_child_has_been_uploaded()

def upload_class_list_to_school_2(
self, file_paths: str, verify_on_children: bool = False, year_group: str = child_year_group.ALL
Expand All @@ -626,14 +623,13 @@ def upload_class_list_to_school_2(
self.select_year_group(year_group=year_group)
self.choose_file_child_records_for_school_2(file_path=_input_file_path)
self.click_continue()
self.__record_upload_time()
self._record_upload_time()
if self.ce.get_file_record_count() > record_limit.FILE_RECORD_MIN_THRESHOLD:
self.po.act(locator=None, action=framework_actions.WAIT, value=wait_time.MED)
if self.ce.get_file_record_count() > record_limit.FILE_RECORD_MAX_THRESHOLD:
self.click_uploaded_file_datetime()
self.verify_upload_output(file_path=_output_file_path)
if verify_on_children:
self.children_page.verify_child_exists()
self.children_page.verify_child_has_been_uploaded()

def set_gillick_competence_for_student(self):
self.click_today()
Expand Down
5 changes: 5 additions & 0 deletions test_data/child/i_mav_1080.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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<<FNAME>> , C<<LNAME>> , <<SCHOOL_1_URN>> , 2010-01-01 , <<NHS_NO>> , Male , Addr1 , Addr2 , Town , AA1 1AA , 8T5 , Parent1 , Dad , [email protected] , , Parent2 , Mum , [email protected] , , 9
Tabs,C<<FNAME>> , C<<LNAME>> , 888888 , 20110101 , <<NHS_NO>> , Male , Addr1 , Addr2 , Town , AA1 1AA , 8T5 , Parent1 , Dad , [email protected] , , Parent2 , Mum , [email protected] , , 9
SingleSpace,C<<FNAME>> , C<<LNAME>> , 999999 , 20100101 , <<NHS_NO>> , Male , Addr1 , Addr2 , Town , AA1 1AA , 8T5 , Parent1 , Dad , [email protected] , , Parent2 , Mum , [email protected] , , 9
LeadingSpaces, C <<FNAME>>,C<<LNAME>>,<<SCHOOL_1_URN>>,20100101,<<NHS_NO>>,Male,Addr1,Addr2,Town,AA11AA,8T5,Parent1,Dad,[email protected],,Parent2,Mum,[email protected],,
1 change: 0 additions & 1 deletion test_data/child/i_positive.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ C<<FNAME>>,C<<LNAME>>,<<SCHOOL_1_URN>>,20100101,<<NHS_NO>>,Male,Addr1,Addr2,Town
C<<FNAME>>,C<<LNAME>>,888888,20100101,<<NHS_NO>>,Male,Addr1,Addr2,Town,AA1 1AA,8T5,Parent1,Dad,[email protected],,Parent2,Mum,[email protected],,9
C<<FNAME>>,C<<LNAME>>,999999,20100101,<<NHS_NO>>,Male,Addr1,Addr2,Town,AA1 1AA,8T5,Parent1,Dad,[email protected],,Parent2,Mum,[email protected],,9
C<<FNAME>>,C<<LNAME>>,<<SCHOOL_1_URN>>,20100101,<<NHS_NO>>,Male,Addr1,Addr2,Town,AA1 1AA,8T5,Parent1,Dad,[email protected],,Parent2,Mum,[email protected],,

1 change: 1 addition & 0 deletions test_data/child/o_mav_1080.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4 children
1 change: 1 addition & 0 deletions test_data/file_mapping.csv
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ CHILD_NEGATIVE,test_data/child/i_negative.csv,test_data/child/o_negative.csv,chi
CHILD_INVALID_STRUCTURE,test_data/child/i_invalid_structure.csv,test_data/child/o_invalid_structure.csv,childstruc
CHILD_EMPTY_FILE,test_data/child/i_empty.csv,test_data/child/o_empty.csv,childempty
CHILD_HEADER_ONLY,test_data/child/i_header_only.csv,test_data/child/o_header_only.csv,childheadonly
CHILD_MAV_1080,test_data/child/i_mav_1080.csv,test_data/child/o_mav_1080.csv,childmav1080
CLASS_POSITIVE,test_data/class_list/i_positive.csv,test_data/class_list/o_positive.csv,classpos
CLASS_NEGATIVE,test_data/class_list/i_negative.csv,test_data/class_list/o_negative.csv,classneg
CLASS_INVALID_STRUCTURE,test_data/class_list/i_invalid_structure.csv,test_data/class_list/o_invalid_structure.csv,classstruc
Expand Down
8 changes: 8 additions & 0 deletions tests/test_03_import_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ def test_child_list_no_record(self, setup_child_list):
def test_child_list_empty_file(self, setup_child_list):
self.import_records_page.import_child_records(file_paths=test_data_file_paths.CHILD_EMPTY_FILE)

@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
)

########################################### CLASS LIST ###########################################

@pytest.mark.classlist
Expand Down
Loading