Skip to content

Commit 59bf020

Browse files
committed
WiP
1 parent 0e51819 commit 59bf020

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

e2e_batch/constants.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
PERMISSIONS_CONFIG_FILE_KEY = "permissions_config.json"
1919

2020

21-
def create_row(unique_id, dose_amount, action_flag, header):
21+
def create_row(unique_id, dose_amount, action_flag, header, inject_char=None):
2222
"""Helper function to create a single row with the specified UNIQUE_ID and ACTION_FLAG."""
2323

24+
name = "James" if not inject_char else b'Jam\xe9s'
25+
2426
return {
2527
header: "9732928395",
2628
"PERSON_FORENAME": "PHYLIS",
27-
"PERSON_SURNAME": "James",
29+
"PERSON_SURNAME": name,
2830
"PERSON_DOB": "20080217",
2931
"PERSON_GENDER_CODE": "0",
3032
"PERSON_POSTCODE": "WD25 0DZ",
@@ -35,7 +37,7 @@ def create_row(unique_id, dose_amount, action_flag, header):
3537
"UNIQUE_ID_URI": "https://www.ravs.england.nhs.uk/",
3638
"ACTION_FLAG": action_flag,
3739
"PERFORMING_PROFESSIONAL_FORENAME": "PHYLIS",
38-
"PERFORMING_PROFESSIONAL_SURNAME": "James",
40+
"PERFORMING_PROFESSIONAL_SURNAME": name,
3941
"RECORDED_DATE": datetime.now(timezone.utc).strftime("%Y%m%d"),
4042
"PRIMARY_SOURCE": "TRUE",
4143
"VACCINATION_PROCEDURE_CODE": "956951000000104",

e2e_batch/test_e2e_batch.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
validate_row_count,
88
generate_csv_files,
99
TestData,
10-
poll_destination,
1110
DestinationType,
1211
)
1312
import logging
@@ -30,10 +29,9 @@
3029
TestData("Update", "8HK48", [CREATE, UPDATE]),
3130
TestData("Delete", "8HA94", [CREATE, UPDATE, DELETE]),
3231
TestData("Reinstate", "X26", [CREATE, DELETE, UPDATE]),
33-
# TestData("Update-Reinstate", "X8E5B", [CREATE, DELETE, UPDATE, UPDATE]),
34-
# TestData("Update-No Create", "YGM41", [UPDATE], success=False),
35-
# TestData("Delete-No Create", "YGJ", [DELETE], success=False),
36-
# TestData("Create with extended ascii characters in name", "YGA", [CREATE], inject_char=True),
32+
TestData("Update no Create", "YGM41", [UPDATE], success=False),
33+
TestData("Delete no Create", "YGJ", [DELETE], success=False),
34+
TestData("Create with extended ascii characters in name", "YGA", [CREATE], inject_char=True),
3735
]
3836

3937
logging.basicConfig(level="INFO")
@@ -51,10 +49,10 @@ def test_create_success(self):
5149

5250
test_datas: list[TestData] = generate_csv_files(seed_datas)
5351

54-
for test in test_datas:
55-
56-
key = upload_file_to_s3(test.file_name, SOURCE_BUCKET, INPUT_PREFIX)
57-
test.key = key
52+
for test_data in test_datas:
53+
logging.info(f"Upload {test_data.file_name}")
54+
key = upload_file_to_s3(test_data.file_name, SOURCE_BUCKET, INPUT_PREFIX)
55+
test_data.key = key
5856

5957
# dictionary of file name to track whether inf and bus acks have been received
6058
start_time = time.time()
@@ -63,15 +61,7 @@ def test_create_success(self):
6361
while pending and (time.time() - start_time) < max_timeout:
6462
pending = False
6563
for test_data in test_datas:
66-
# loop through keys in test (inf and bus)
67-
for ack_key in test_data.ack_keys.keys():
68-
if not test_data.ack_keys[ack_key]:
69-
found_ack_key = poll_destination(test_data.file_name, ack_key)
70-
if found_ack_key:
71-
test_data.ack_keys[ack_key] = found_ack_key
72-
logging.info(f"Found {ack_key} ack for {test_data.file_name}: {found_ack_key}")
73-
else:
74-
pending = True
64+
pending = test_data.poll_destination(pending, logging)
7565
if pending:
7666
time.sleep(1)
7767

@@ -90,4 +80,3 @@ def test_create_success(self):
9080
# bus_ack_content = get_file_content_from_s3(ACK_BUCKET, test_data.ack_keys[DestinationType.BUS])
9181

9282
logging.info(f"Completed all validations. Total time taken: {time.time() - start_time:.1f} seconds")
93-

e2e_batch/utils.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ def __init__(self, description, vax_ods, actions: list, header="NHS_NUMBER",
5959
self.key = None
6060
self.ack_keys = {DestinationType.INF: None, DestinationType.BUS: None}
6161

62+
def poll_destination(self, pending: bool, logging) -> bool:
63+
# loop through keys in test (inf and bus)
64+
for ack_key in self.ack_keys.keys():
65+
if not self.ack_keys[ack_key]:
66+
found_ack_key = poll_destination(self.file_name, ack_key)
67+
if found_ack_key:
68+
self.ack_keys[ack_key] = found_ack_key
69+
logging.info(f"Found {found_ack_key}")
70+
else:
71+
pending = True
72+
return pending
73+
6274

6375
def generate_csv(dose_amount, action_flag, headers="NHS_NUMBER", same_id=False, version="4",
6476
vax_type="RSV", ods="YGM41"):
@@ -539,10 +551,10 @@ def generate_csv_files(seed_data_list: list[TestData]) -> list[TestData]:
539551

540552
def generate_csv_file(seed: TestData, actions: str) -> str:
541553

542-
unique_id = str(uuid.uuid4())
543554
data = []
544555
for action in actions:
545-
data.append(create_row(unique_id, seed.dose_amount, action, seed.header))
556+
unique_id = str(uuid.uuid4())
557+
data.append(create_row(unique_id, seed.dose_amount, action, seed.header, seed.inject_char))
546558
df = pd.DataFrame(data)
547559
file_name = get_file_name(seed.vax, seed.ods, seed.version)
548560
df.to_csv(file_name, index=False, sep="|", quoting=csv.QUOTE_MINIMAL)

0 commit comments

Comments
 (0)