Skip to content

Commit 76e73fc

Browse files
C20250514 (#148)
* spellings * mav_1080
1 parent 2313cf3 commit 76e73fc

File tree

12 files changed

+80
-30
lines changed

12 files changed

+80
-30
lines changed

.vscode/settings.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,35 @@
1010
"python.testing.unittestEnabled": false,
1111
"python.testing.pytestEnabled": true,
1212
"cSpell.words": [
13+
"careplus",
1314
"childlist",
1415
"CLAST",
1516
"CONFLICTINGCONSENT",
1617
"consentworkflow",
1718
"dotenv",
1819
"downcasting",
20+
"exitstatus",
1921
"fillna",
22+
"GARDASIL",
23+
"GARDASIL9",
24+
"hookwrapper",
2025
"HOYTE",
26+
"MENACWY",
2127
"NOCONSENT",
28+
"nodeid",
2229
"SAIS",
2330
"schoolmoves",
31+
"sessionfinish",
32+
"sessionstart",
33+
"SYSTM",
34+
"SYSTMONE",
35+
"TDIPV",
36+
"tryfirst",
37+
"trylast",
2438
"unmatchedconsentresponses",
25-
"venv",
26-
"GARDASIL","GARDASIL9","VACC","vacc","careplus","MENACWY","TDIPV","SYSTMONE","SYSTM"
39+
"vacc",
40+
"VACC",
41+
"venv"
2742
],
2843
"[python]": {
2944
"editor.defaultFormatter": "ms-python.black-formatter",

libs/generic_constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class escape_characters:
104104
PIPE: Final[str] = "|"
105105
ASTERISK: Final[str] = "*"
106106
QUESTION_MARK: Final[str] = "?"
107+
COMMA: Final[str] = ","
107108
UI_FORMATTING: Final[list[str]] = [
108109
SPACE,
109110
NEW_LINE,
@@ -114,6 +115,7 @@ class escape_characters:
114115
SINGLE_QUOTE_CLOSE_UNICODE,
115116
SINGLE_QUOTE_CLOSE,
116117
TAB,
118+
COMMA,
117119
]
118120
FILE_NAME: Final[list[str]] = [
119121
SEPARATOR_CHAR,

libs/mavis_constants.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ class test_data_values:
4949
EMPTY: Final[str] = "<empty>"
5050

5151

52+
class mavis_file_types:
53+
CHILD_LIST: Final[str] = "childlist"
54+
COHORT: Final[str] = "cohort"
55+
CLASS_LIST: Final[str] = "classlist"
56+
VACCS_MAVIS: Final[str] = "vaccsmavis"
57+
VACCS_SYSTMONE: Final[str] = "vaccssystmone"
58+
59+
5260
class record_limit:
5361
FILE_RECORD_MIN_THRESHOLD: Final[int] = 15
5462
FILE_RECORD_MAX_THRESHOLD: Final[int] = 15
@@ -82,6 +90,7 @@ class test_data_file_paths:
8290
CHILD_INVALID_STRUCTURE: Final[str] = "CHILD_INVALID_STRUCTURE"
8391
CHILD_EMPTY_FILE: Final[str] = "CHILD_EMPTY_FILE"
8492
CHILD_HEADER_ONLY: Final[str] = "CHILD_HEADER_ONLY"
93+
CHILD_MAV_1080: Final[str] = "CHILD_MAV_1080"
8594
CLASS_POSITIVE: Final[str] = "CLASS_POSITIVE"
8695
CLASS_NEGATIVE: Final[str] = "CLASS_NEGATIVE"
8796
CLASS_INVALID_STRUCTURE: Final[str] = "CLASS_INVALID_STRUCTURE"

libs/testdata_ops.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from libs import CurrentExecution, file_ops
55
from libs.generic_constants import escape_characters
6-
from libs.mavis_constants import test_data_values
6+
from libs.mavis_constants import mavis_file_types, test_data_values
77
from libs.wrappers import *
88

99

@@ -143,7 +143,7 @@ def get_file_paths(self, file_paths: str) -> tuple[str, str]:
143143
)
144144
return _input_file_path, _output_template_path
145145

146-
def create_child_list_from_file(self, file_path: str):
146+
def create_child_list_from_file(self, file_path: str, file_type: str):
147147
"""
148148
Create a list of child names from a file.
149149
@@ -153,12 +153,19 @@ def create_child_list_from_file(self, file_path: str):
153153
Returns:
154154
list: List of child names.
155155
"""
156-
if "positive" in file_path.lower():
157-
_file_df = self.fo.read_csv_to_df(file_path=file_path)
158-
_child_list = _file_df[["CHILD_FIRST_NAME", "CHILD_LAST_NAME"]]
159-
return _child_list["CHILD_FIRST_NAME"] + " " + _child_list["CHILD_LAST_NAME"].values.tolist()
160-
else:
161-
return None
156+
_file_df = self.fo.read_csv_to_df(file_path=file_path)
157+
match file_type:
158+
case mavis_file_types.CHILD_LIST | mavis_file_types.COHORT | mavis_file_types.CLASS_LIST:
159+
_child_list = _file_df[["CHILD_FIRST_NAME", "CHILD_LAST_NAME"]]
160+
return _child_list["CHILD_LAST_NAME"] + " " + _child_list["CHILD_FIRST_NAME"].values.tolist()
161+
case mavis_file_types.VACCS_MAVIS:
162+
_child_list = _file_df[["PERSON_FORENAME", "PERSON_SURNAME"]]
163+
return _child_list["PERSON_SURNAME"] + " " + _child_list["PERSON_FIRSTNAME"].values.tolist()
164+
case mavis_file_types.VACCS_SYSTMONE:
165+
_child_list = _file_df[["First name", "Surname"]]
166+
return _child_list["Surname"] + " " + _child_list["First name"].values.tolist()
167+
case _:
168+
return None
162169

163170
def get_session_id(self, excel_path: str) -> str:
164171
"""

pages/pg_children.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ def verify_filter(self):
4444
self.po.act(locator=None, action=framework_actions.WAIT, value=wait_time.MIN)
4545
self.po.verify(locator=self.LBL_MAIN, property=element_properties.TEXT, expected_value=self.LBL_CHILD_RECORD)
4646

47-
def verify_child_exists(self) -> None:
48-
if len(self.ce.child_list) >= 1:
47+
def verify_child_has_been_uploaded(self, child_list: list[str]) -> None:
48+
if len(child_list) >= 1:
4949
self.dashboard_page.go_to_dashboard()
5050
self.dashboard_page.click_children()
51-
for child_name in self.ce.child_list:
52-
self.search_for_a_child(child_name=child_name)
53-
self.po.act(locator=self.LNK_CLEAR_FILTERS, action=framework_actions.CLICK_LINK)
51+
for _child_name in child_list:
52+
_cn = _child_name.strip()
53+
self.search_for_a_child(child_name=_cn)
54+
# self.po.act(locator=self.LNK_CLEAR_FILTERS, action=framework_actions.CLICK_LINK)
5455

5556
def search_for_a_child(self, child_name: str) -> None:
5657
self.po.act(locator=self.TXT_SEARCH, action=framework_actions.FILL, value=child_name)

pages/pg_import_records.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from libs import CurrentExecution, file_ops, playwright_ops, testdata_ops
44
from libs.generic_constants import element_properties, framework_actions, wait_time
5-
from libs.mavis_constants import child_year_group, record_limit
5+
from libs.mavis_constants import child_year_group, mavis_file_types, record_limit
66
from libs.wrappers import *
77
from pages import pg_children, pg_dashboard, pg_sessions, pg_vaccines
88

@@ -25,11 +25,8 @@ class pg_import_records:
2525
RDO_VACCINATION_RECORDS: Final[str] = "Vaccination records"
2626
BTN_CONTINUE: Final[str] = "Continue"
2727
LBL_CHILD_RECORDS: Final[str] = "Upload file"
28-
# LBL_CLASS_LIST_RECORDS: Final[str] = f"{sessions_page.LNK_SCHOOL_1}Import"
2928
LBL_CLASS_LIST_RECORDS: Final[str] = "Upload file"
30-
# LBL_VACCINATION_RECORDS: Final[str] = "Vaccination records"
3129
LBL_VACCINATION_RECORDS: Final[str] = "Upload file"
32-
# LBL_CLASS_LIST_RECORDS_FOR_SCHOOL1: Final[str] = f"{sessions_page.LNK_SCHOOL_1}Import"
3330
LBL_CLASS_LIST_RECORDS_FOR_SCHOOL1: Final[str] = "Upload file"
3431
LBL_SCHOOL_NAME: Final[str] = "Which school is this class"
3532
LBL_MAIN: Final[str] = "main"
@@ -39,11 +36,18 @@ class pg_import_records:
3936
CHK_YEAR11: Final[str] = "Year 11"
4037
LNK_IMPORT_CLASS_LIST_RECORDS: Final[str] = "Import class lists"
4138

39+
def __init__(self):
40+
self.upload_time = ""
41+
4242
def click_import_records(self):
4343
self.po.act(locator=self.LNK_IMPORT_RECORDS, action=framework_actions.CLICK_LINK)
4444

45-
def import_child_records(self, file_paths: str):
45+
def import_child_records(self, file_paths: str, verify_on_children_page: bool = False):
4646
_input_file_path, _output_file_path = self.tdo.get_file_paths(file_paths=file_paths)
47+
if verify_on_children_page:
48+
_cl = self.tdo.create_child_list_from_file(
49+
file_path=_input_file_path, file_type=mavis_file_types.CHILD_LIST
50+
)
4751
self.po.act(locator=self.RDO_CHILD_RECORDS, action=framework_actions.RADIO_BUTTON_SELECT)
4852
self.po.act(locator=self.BTN_CONTINUE, action=framework_actions.CLICK_BUTTON)
4953
self.po.act(
@@ -57,6 +61,8 @@ def import_child_records(self, file_paths: str):
5761
if self.ce.get_file_record_count() > record_limit.FILE_RECORD_MAX_THRESHOLD:
5862
self._click_uploaded_file_datetime(truncated=True)
5963
self._verify_upload_output(file_path=_output_file_path)
64+
if verify_on_children_page:
65+
self.children_page.verify_child_has_been_uploaded(child_list=_cl)
6066

6167
def import_class_list_records(self, file_paths: str, year_group: str = child_year_group.ALL):
6268
_input_file_path, _output_file_path = self.tdo.get_file_paths(file_paths=file_paths)

pages/pg_sessions.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ class pg_sessions:
5353
LNK_TAB_ACTIVITY_LOG: Final[str] = "Activity log"
5454
LNK_TAB_REGISTER: Final[str] = "Register"
5555
LNK_IMPORT_CLASS_LIST: Final[str] = "Import class lists"
56-
# LBL_CHOOSE_COHORT_FILE_1: str = f"{LNK_SCHOOL_1}Import class"
57-
# LBL_CHOOSE_COHORT_FILE_2: str = f"{LNK_SCHOOL_2}Import class"
5856
LBL_CHOOSE_COHORT_FILE_1: str = "Upload file"
5957
LBL_CHOOSE_COHORT_FILE_2: str = "Upload file"
6058
BTN_CONTINUE: Final[str] = "Continue"
@@ -130,7 +128,7 @@ def __get_display_formatted_date(self, date_to_format: str) -> str:
130128
_formatted_date = _parsed_date.strftime("%A %d %B %Y").replace(" 0", " ")
131129
return _formatted_date
132130

133-
def __record_upload_time(self):
131+
def _record_upload_time(self):
134132
self.upload_time = get_link_formatted_date_time()
135133

136134
def click_uploaded_file_datetime(self):
@@ -607,14 +605,13 @@ def upload_class_list_to_school_1(
607605
self.select_year_group(year_group=year_group)
608606
self.choose_file_child_records_for_school_1(file_path=_input_file_path)
609607
self.click_continue()
610-
self.__record_upload_time()
608+
self._record_upload_time()
611609
if self.ce.get_file_record_count() > record_limit.FILE_RECORD_MIN_THRESHOLD:
612610
self.po.act(locator=None, action=framework_actions.WAIT, value=wait_time.MED)
613-
if self.ce.get_file_record_count() > record_limit.FILE_RECORD_MAX_THRESHOLD:
614611
self.click_uploaded_file_datetime()
615612
self.verify_upload_output(file_path=_output_file_path)
616613
if verify_on_children:
617-
self.children_page.verify_child_exists()
614+
self.children_page.verify_child_has_been_uploaded()
618615

619616
def upload_class_list_to_school_2(
620617
self, file_paths: str, verify_on_children: bool = False, year_group: str = child_year_group.ALL
@@ -626,14 +623,13 @@ def upload_class_list_to_school_2(
626623
self.select_year_group(year_group=year_group)
627624
self.choose_file_child_records_for_school_2(file_path=_input_file_path)
628625
self.click_continue()
629-
self.__record_upload_time()
626+
self._record_upload_time()
630627
if self.ce.get_file_record_count() > record_limit.FILE_RECORD_MIN_THRESHOLD:
631628
self.po.act(locator=None, action=framework_actions.WAIT, value=wait_time.MED)
632-
if self.ce.get_file_record_count() > record_limit.FILE_RECORD_MAX_THRESHOLD:
633629
self.click_uploaded_file_datetime()
634630
self.verify_upload_output(file_path=_output_file_path)
635631
if verify_on_children:
636-
self.children_page.verify_child_exists()
632+
self.children_page.verify_child_has_been_uploaded()
637633

638634
def set_gillick_competence_for_student(self):
639635
self.click_today()

test_data/child/i_mav_1080.csv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
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
2+
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
3+
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
4+
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
5+
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],,

test_data/child/i_positive.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ C<<FNAME>>,C<<LNAME>>,<<SCHOOL_1_URN>>,20100101,<<NHS_NO>>,Male,Addr1,Addr2,Town
33
C<<FNAME>>,C<<LNAME>>,888888,20100101,<<NHS_NO>>,Male,Addr1,Addr2,Town,AA1 1AA,8T5,Parent1,Dad,[email protected],,Parent2,Mum,[email protected],,9
44
C<<FNAME>>,C<<LNAME>>,999999,20100101,<<NHS_NO>>,Male,Addr1,Addr2,Town,AA1 1AA,8T5,Parent1,Dad,[email protected],,Parent2,Mum,[email protected],,9
55
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],,
6-

test_data/child/o_mav_1080.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4 children

0 commit comments

Comments
 (0)