Skip to content

Commit 2a8d64f

Browse files
mav1080
1 parent 7d22aa8 commit 2a8d64f

File tree

8 files changed

+93
-34
lines changed

8 files changed

+93
-34
lines changed

libs/testdata_ops.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def get_file_paths(self, file_paths: str) -> tuple[str, str]:
142142
)
143143
return _input_file_path, _output_template_path
144144

145-
def create_child_list_from_file(self, file_path: str, file_type: str):
145+
def create_child_list_from_file(self, file_path: str, file_type: mavis_file_types):
146146
"""
147147
Create a list of child names from a file.
148148
@@ -153,18 +153,21 @@ def create_child_list_from_file(self, file_path: str, file_type: str):
153153
list: List of child names.
154154
"""
155155
_file_df = self.fo.read_csv_to_df(file_path=file_path)
156+
# _file_df.replace("\xa0", " ", regex=False, inplace=True) # NBSP
157+
# _file_df.replace("\u200d", " ", regex=False, inplace=True) # ZWJ
156158
match file_type:
157159
case mavis_file_types.CHILD_LIST | mavis_file_types.COHORT | mavis_file_types.CLASS_LIST:
158160
_child_list = _file_df[["CHILD_FIRST_NAME", "CHILD_LAST_NAME"]]
159-
return _child_list["CHILD_LAST_NAME"] + ", " + _child_list["CHILD_FIRST_NAME"].values.tolist()
161+
_list = _child_list["CHILD_LAST_NAME"] + ", " + _child_list["CHILD_FIRST_NAME"].values.tolist()
160162
case mavis_file_types.VACCS_MAVIS:
161163
_child_list = _file_df[["PERSON_FORENAME", "PERSON_SURNAME"]]
162-
return _child_list["PERSON_SURNAME"] + ", " + _child_list["PERSON_FIRSTNAME"].values.tolist()
164+
_list = _child_list["PERSON_SURNAME"] + ", " + _child_list["PERSON_FORENAME"].values.tolist()
163165
case mavis_file_types.VACCS_SYSTMONE:
164166
_child_list = _file_df[["First name", "Surname"]]
165-
return _child_list["Surname"] + ", " + _child_list["First name"].values.tolist()
166-
case _:
167-
return None
167+
_list = _child_list["Surname"] + ", " + _child_list["First name"].values.tolist()
168+
_list = _list.replace(" ", " ")
169+
_list = _list.replace("\u200d", " ")
170+
return _list
168171

169172
def get_session_id(self, excel_path: str) -> str:
170173
"""

pages/pg_children.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ def verify_child_has_been_uploaded(self, child_list) -> None:
4949
self.dashboard_page.go_to_dashboard()
5050
self.dashboard_page.click_children()
5151
for _child_name in child_list:
52-
_cn = _child_name.strip()
52+
_cn: str = _child_name.strip()
53+
_cn = _cn.replace("\xa0", " ")
54+
_cn = _cn.replace("\u200d", " ")
5355
self.search_for_a_child(child_name=_cn)
5456
# self.po.act(locator=self.LNK_CLEAR_FILTERS, action=framework_actions.CLICK_LINK)
5557

pages/pg_import_records.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,15 @@ def import_class_list_records_from_school_session(self, file_paths: str):
112112
self._click_uploaded_file_datetime(truncated=True)
113113
self._verify_upload_output(file_path=_output_file_path)
114114

115-
def import_vaccination_records(self, file_paths: str):
115+
def import_vaccination_records(
116+
self,
117+
file_paths: str,
118+
file_type: mavis_file_types = mavis_file_types.VACCS_MAVIS,
119+
verify_on_children_page: bool = False,
120+
):
116121
_input_file_path, _output_file_path = self.tdo.get_file_paths(file_paths=file_paths)
122+
if verify_on_children_page:
123+
_cl = self.tdo.create_child_list_from_file(file_path=_input_file_path, file_type=file_type)
117124
self.po.act(locator=self.LNK_IMPORT_RECORDS, action=framework_actions.CLICK_LINK)
118125
self.po.act(locator=self.RDO_VACCINATION_RECORDS, action=framework_actions.RADIO_BUTTON_SELECT)
119126
self.po.act(locator=self.BTN_CONTINUE, action=framework_actions.CLICK_BUTTON)
@@ -128,6 +135,8 @@ def import_vaccination_records(self, file_paths: str):
128135
if self.ce.get_file_record_count() > record_limit.FILE_RECORD_MAX_THRESHOLD:
129136
self._click_uploaded_file_datetime(truncated=True)
130137
self._verify_upload_output(file_path=_output_file_path)
138+
if verify_on_children_page:
139+
self.children_page.verify_child_has_been_uploaded(child_list=_cl)
131140

132141
def _record_upload_time(self):
133142
self.upload_time = get_link_formatted_date_time()

test_data/vaccs/i_mav_1080.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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
22
TwoSpaces,<<ORG_CODE>> , <<SCHOOL_1_URN>> , <<SCHOOL_1_NAME>> , <<NHS_NO>> , <<FNAME>> , <<LNAME>> , <<DOB_YEAR_9>> , Male , DN9 1PB , <<VACCS_DATE>> , Gardasil9 , AutoBatch1 , 20301231 , Left Thigh , 1 , Y , 1 , , , [email protected] , Clinic , 00:01 , , <<SESSION_ID>> , HPV
33
Tabs,<<ORG_CODE>> , <<SCHOOL_1_URN>> , <<SCHOOL_1_NAME>> , <<NHS_NO>> , <<FNAME>> , <<LNAME>> , <<DOB_YEAR_9>> , Male , DN9 1PB , <<VACCS_DATE>> , Gardasil , AutoBatch1 , 20301231 , Right Thigh , 2 , Y , 1 , , , [email protected] , Clinic , 00:01 , , <<SESSION_ID>> , HPV
4-
NBSP,<<ORG_CODE>>,<<SCHOOL_1_URN>>,<<SCHOOL_1_NAME>>,<<NHS_NO>>,C <<FNAME>>,<<LNAME>>,<<DOB_YEAR_9>>,Male,DN9 1PB,<<VACCS_DATE>>,Cervarix,AutoBatch1,20301231,left upper arm,3,Y,1,,,[email protected],Clinic,00:01,,<<SESSION_ID>>,HPV
5-
ZWJ,<<ORG_CODE>>,<<SCHOOL_1_URN>>,<<SCHOOL_1_NAME>>,<<NHS_NO>>,C‍<<FNAME>>,<<LNAME>>,<<DOB_YEAR_9>>,Male,ZZ99 3VZ,<<VACCS_DATE>>,Gardasil9,AutoBatch1,20301231,left arm (upper position),1,Y,1,,,[email protected],Clinic,00:01,,<<SESSION_ID>>,HPV
4+
NBSP,<<ORG_CODE>>,<<SCHOOL_1_URN>>,<<SCHOOL_1_NAME>>,<<NHS_NO>>,NBSP <<FNAME>>,<<LNAME>>,<<DOB_YEAR_9>>,Male,DN9 1PB,<<VACCS_DATE>>,Cervarix,AutoBatch1,20301231,left upper arm,3,Y,1,,,[email protected],Clinic,00:01,,<<SESSION_ID>>,HPV
5+
ZWJ,<<ORG_CODE>>,<<SCHOOL_1_URN>>,<<SCHOOL_1_NAME>>,<<NHS_NO>>,ZWJ‍<<FNAME>>,<<LNAME>>,<<DOB_YEAR_9>>,Male,ZZ99 3VZ,<<VACCS_DATE>>,Gardasil9,AutoBatch1,20301231,left arm (upper position),1,Y,1,,,[email protected],Clinic,00:01,,<<SESSION_ID>>,HPV
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
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
22
TwoSpaces, <<DOB_YEAR_10>> , <<NHS_NO>> , , 123013325 , , Cervarix 1 , C<<FNAME>> , LE3 2DA , Female , C<<LNAME>> , <<VACCS_DATE>> , School , <<VACCS_TIME>> , <<ORG_CODE>> , <<SCHOOL_1_NAME>> , <<SCHOOL_1_URN>> ,
33
Tabs,<<DOB_YEAR_10>> , <<NHS_NO>> , , 123013325 , , Gardasil9 1 , C<<FNAME>> , LE3 2DA , Female , C<<LNAME>> , <<VACCS_DATE>> , School , <<VACCS_TIME>> , <<ORG_CODE>> , <<SCHOOL_1_NAME>> , <<SCHOOL_1_URN>> ,
4-
NBSP,<<DOB_YEAR_10>>,<<NHS_NO>>,,123013325,,Gard asil9 1,C<<FNAME>>,LE3 2DA,Female,C<<LNAME>>,<<VACCS_DATE>>,School,<<VACCS_TIME>>,<<ORG_CODE>>,<<SCHOOL_1_NAME>>,<<SCHOOL_1_URN>>,
5-
ZWJ,<<DOB_YEAR_10>>,<<NHS_NO>>,,123013325,,Gar‍dasil9 1,C<<FNAME>>,LE3 2DA,Female,C<<LNAME>>,<<VACCS_DATE>>,School,<<VACCS_TIME>>,<<ORG_CODE>>,<<SCHOOL_1_NAME>>,<<SCHOOL_1_URN>>,
4+
NBSP,<<DOB_YEAR_10>>,<<NHS_NO>>,,123013325,,Gardasil9 1,NBSP <<FNAME>>,LE3 2DA,Female,C<<LNAME>>,<<VACCS_DATE>>,School,<<VACCS_TIME>>,<<ORG_CODE>>,<<SCHOOL_1_NAME>>,<<SCHOOL_1_URN>>,
5+
ZWJ,<<DOB_YEAR_10>>,<<NHS_NO>>,,123013325,,Gardasil9 1,ZWJ‍<<FNAME>>,LE3 2DA,Female,C<<LNAME>>,<<VACCS_DATE>>,School,<<VACCS_TIME>>,<<ORG_CODE>>,<<SCHOOL_1_NAME>>,<<SCHOOL_1_URN>>,
66
HistoricalTwoSpaces, <<DOB_YEAR_10>> , <<NHS_NO>> , , 123013325 , , Cervarix 1 , C<<FNAME>> , LE3 2DA , Female , C<<LNAME>> , <<HIST_VACCS_DATE>> , School , <<VACCS_TIME>> , <<ORG_CODE>> , <<SCHOOL_1_NAME>> , <<SCHOOL_1_URN>> ,
77
HistoricalTabs,<<DOB_YEAR_10>> , <<NHS_NO>> , , 123013325 , , Gardasil9 1 , C<<FNAME>> , LE3 2DA , Female , C<<LNAME>> , <<HIST_VACCS_DATE>> , School , <<VACCS_TIME>> , <<ORG_CODE>> , <<SCHOOL_1_NAME>> , <<SCHOOL_1_URN>> ,
8-
HistoricalNBSP,<<DOB_YEAR_10>>,<<NHS_NO>>,,123013325,,Gard asil9 1,C<<FNAME>>,LE3 2DA,Female,C<<LNAME>>,<<HIST_VACCS_DATE>>,School,<<VACCS_TIME>>,<<ORG_CODE>>,<<SCHOOL_1_NAME>>,<<SCHOOL_1_URN>>,
9-
HistoricalZWJ,<<DOB_YEAR_10>>,<<NHS_NO>>,,123013325,,Gar‍dasil9 1,C<<FNAME>>,LE3 2DA,Female,C<<LNAME>>,<<HIST_VACCS_DATE>>,School,<<VACCS_TIME>>,<<ORG_CODE>>,<<SCHOOL_1_NAME>>,<<SCHOOL_1_URN>>,
8+
HistoricalNBSP,<<DOB_YEAR_10>>,<<NHS_NO>>,,123013325,,Gardasil9 1,NBSP <<FNAME>>,LE3 2DA,Female,C<<LNAME>>,<<HIST_VACCS_DATE>>,School,<<VACCS_TIME>>,<<ORG_CODE>>,<<SCHOOL_1_NAME>>,<<SCHOOL_1_URN>>,
9+
HistoricalZWJ,<<DOB_YEAR_10>>,<<NHS_NO>>,,123013325,,Gardasil9 1,ZWJ‍<<FNAME>>,LE3 2DA,Female,C<<LNAME>>,<<HIST_VACCS_DATE>>,School,<<VACCS_TIME>>,<<ORG_CODE>>,<<SCHOOL_1_NAME>>,<<SCHOOL_1_URN>>,

tests/test_03_import_records.py

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import pytest
22

3-
from libs.mavis_constants import child_year_group, test_data_file_paths
3+
from libs.mavis_constants import (
4+
child_year_group,
5+
mavis_file_types,
6+
test_data_file_paths,
7+
)
48
from pages import pg_dashboard, pg_import_records, pg_login, pg_sessions
59

610

@@ -144,77 +148,109 @@ def test_class_list_space_normalization(self, setup_class_list: None):
144148
@pytest.mark.vaccinations
145149
@pytest.mark.order(351)
146150
def test_vaccs_positive_file_upload(self, setup_vaccs):
147-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_POSITIVE)
151+
self.import_records_page.import_vaccination_records(
152+
file_paths=test_data_file_paths.VACCS_POSITIVE, file_type=mavis_file_types.VACCS_MAVIS
153+
)
148154

149155
@pytest.mark.vaccinations
150156
@pytest.mark.order(352)
151157
def test_vaccs_negative_file_upload(self, setup_vaccs):
152-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_NEGATIVE)
158+
self.import_records_page.import_vaccination_records(
159+
file_paths=test_data_file_paths.VACCS_NEGATIVE, file_type=mavis_file_types.VACCS_MAVIS
160+
)
153161

154162
@pytest.mark.vaccinations
155163
@pytest.mark.order(353)
156164
def test_vaccs_duplicate_record_upload(self, setup_vaccs):
157-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_DUP_1)
165+
self.import_records_page.import_vaccination_records(
166+
file_paths=test_data_file_paths.VACCS_DUP_1, file_type=mavis_file_types.VACCS_MAVIS
167+
)
158168
self.dashboard_page.go_to_dashboard()
159169
self.dashboard_page.click_import_records()
160-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_DUP_2)
170+
self.import_records_page.import_vaccination_records(
171+
file_paths=test_data_file_paths.VACCS_DUP_2, file_type=mavis_file_types.VACCS_MAVIS
172+
)
161173

162174
@pytest.mark.vaccinations
163175
@pytest.mark.order(354)
164176
def test_vaccs_file_structure(self, setup_vaccs):
165-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_INVALID_STRUCTURE)
177+
self.import_records_page.import_vaccination_records(
178+
file_paths=test_data_file_paths.VACCS_INVALID_STRUCTURE, file_type=mavis_file_types.VACCS_MAVIS
179+
)
166180

167181
@pytest.mark.vaccinations
168182
@pytest.mark.order(355)
169183
def test_vaccs_no_record(self, setup_vaccs):
170-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_HEADER_ONLY)
184+
self.import_records_page.import_vaccination_records(
185+
file_paths=test_data_file_paths.VACCS_HEADER_ONLY, file_type=mavis_file_types.VACCS_MAVIS
186+
)
171187

172188
@pytest.mark.vaccinations
173189
@pytest.mark.order(356)
174190
def test_vaccs_empty_file(self, setup_vaccs):
175-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_EMPTY_FILE)
191+
self.import_records_page.import_vaccination_records(
192+
file_paths=test_data_file_paths.VACCS_EMPTY_FILE, file_type=mavis_file_types.VACCS_MAVIS
193+
)
176194

177195
@pytest.mark.vaccinations
178196
@pytest.mark.order(357)
179197
def test_vaccs_historic_positive_file_upload(self, setup_vaccs):
180-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_HIST_POSITIVE)
198+
self.import_records_page.import_vaccination_records(
199+
file_paths=test_data_file_paths.VACCS_HIST_POSITIVE, file_type=mavis_file_types.VACCS_MAVIS
200+
)
181201

182202
@pytest.mark.vaccinations
183203
@pytest.mark.order(358)
184204
def test_vaccs_historic_negative_file_upload(self, setup_vaccs):
185-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_HIST_NEGATIVE)
205+
self.import_records_page.import_vaccination_records(
206+
file_paths=test_data_file_paths.VACCS_HIST_NEGATIVE, file_type=mavis_file_types.VACCS_MAVIS
207+
)
186208

187209
@pytest.mark.vaccinations
188210
@pytest.mark.order(359)
189211
def test_vaccs_historic_no_urn_mav_855(self, setup_vaccs):
190-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_HPV_MAV_855)
212+
self.import_records_page.import_vaccination_records(
213+
file_paths=test_data_file_paths.VACCS_HPV_MAV_855, file_type=mavis_file_types.VACCS_MAVIS
214+
)
191215
self.dashboard_page.go_to_dashboard()
192216
self.dashboard_page.click_children()
193217
self.import_records_page.verify_mav_855()
194218

195219
@pytest.mark.vaccinations
196220
@pytest.mark.order(360)
197221
def test_vaccs_systmone_positive_file_upload(self, setup_vaccs_systmone):
198-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_SYSTMONE_POSITIVE)
222+
self.import_records_page.import_vaccination_records(
223+
file_paths=test_data_file_paths.VACCS_SYSTMONE_POSITIVE, file_type=mavis_file_types.VACCS_SYSTMONE
224+
)
199225

200226
@pytest.mark.vaccinations
201227
@pytest.mark.order(361)
202228
def test_vaccs_systmone_negative_file_upload(self, setup_vaccs_systmone):
203-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_SYSTMONE_NEGATIVE)
229+
self.import_records_page.import_vaccination_records(
230+
file_paths=test_data_file_paths.VACCS_SYSTMONE_NEGATIVE, file_type=mavis_file_types.VACCS_SYSTMONE
231+
)
204232

205233
@pytest.mark.vaccinations
206234
@pytest.mark.order(362)
207235
def test_vaccs_systmone_negative_historical_file_upload(self, setup_vaccs_systmone):
208236
self.import_records_page.import_vaccination_records(
209-
file_paths=test_data_file_paths.VACCS_SYSTMONE_HIST_NEGATIVE
237+
file_paths=test_data_file_paths.VACCS_SYSTMONE_HIST_NEGATIVE, file_type=mavis_file_types.VACCS_SYSTMONE
210238
)
211239

212240
@pytest.mark.vaccinations
213241
@pytest.mark.order(363)
214242
def test_vaccs_hpv_space_normalization(self, setup_vaccs):
215-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_MAV_1080)
243+
self.import_records_page.import_vaccination_records(
244+
file_paths=test_data_file_paths.VACCS_MAV_1080,
245+
verify_on_children_page=True,
246+
file_type=mavis_file_types.VACCS_MAVIS,
247+
)
216248

217249
@pytest.mark.vaccinations
218250
@pytest.mark.order(364)
219251
def test_vaccs_systmone_space_normalization(self, setup_vaccs_systmone):
220-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_SYSTMONE_POSITIVE)
252+
self.import_records_page.import_vaccination_records(
253+
file_paths=test_data_file_paths.VACCS_SYSTMONE_MAV_1080,
254+
verify_on_children_page=False,
255+
file_type=mavis_file_types.VACCS_SYSTMONE,
256+
)

tests/test_05_programmes.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import pytest
22

3-
from libs.mavis_constants import programmes, test_data_file_paths, vaccines
3+
from libs.mavis_constants import (
4+
mavis_file_types,
5+
programmes,
6+
test_data_file_paths,
7+
vaccines,
8+
)
49
from pages import (
510
pg_dashboard,
611
pg_import_records,
@@ -54,7 +59,9 @@ def setup_mavis_1729(self, start_mavis: None):
5459
self.sessions_page.save_session_id_from_offline_excel()
5560
self.dashboard_page.go_to_dashboard()
5661
self.dashboard_page.click_import_records()
57-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_HPV_DOSE_TWO)
62+
self.import_records_page.import_vaccination_records(
63+
file_paths=test_data_file_paths.VACCS_HPV_DOSE_TWO, file_type=mavis_file_types.VACCS_MAVIS
64+
)
5865
self.dashboard_page.go_to_dashboard()
5966
self.dashboard_page.click_programmes()
6067
yield

tests/test_07_children.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from libs.mavis_constants import test_data_file_paths
3+
from libs.mavis_constants import mavis_file_types, test_data_file_paths
44
from pages import (
55
pg_children,
66
pg_dashboard,
@@ -74,7 +74,9 @@ def setup_mav_853(self, setup_tests: None):
7474
self.programmes_page.upload_cohorts(file_paths=test_data_file_paths.COHORTS_MAV_853)
7575
self.dashboard_page.go_to_dashboard()
7676
self.dashboard_page.click_import_records()
77-
self.import_records_page.import_vaccination_records(file_paths=test_data_file_paths.VACCS_MAV_853)
77+
self.import_records_page.import_vaccination_records(
78+
file_paths=test_data_file_paths.VACCS_MAV_853, file_type=mavis_file_types.VACCS_MAVIS
79+
)
7880
self.dashboard_page.go_to_dashboard()
7981
self.dashboard_page.click_children()
8082
yield

0 commit comments

Comments
 (0)