Skip to content

Commit 817f2f8

Browse files
committed
wip
1 parent 9585507 commit 817f2f8

File tree

2 files changed

+22
-31
lines changed

2 files changed

+22
-31
lines changed

e2e_batch/test_e2e_batch.py

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from constants import (
1515
SOURCE_BUCKET,
1616
INPUT_PREFIX,
17+
ACK_BUCKET,
1718
environment
1819
)
1920

@@ -49,40 +50,29 @@ def test_create_success(self):
4950
test.key = key
5051

5152
# dictionary of file name to track whether inf and bus acks have been received
52-
pending = {test.file_name: {DestinationType.INF: True, DestinationType.BUS: True} for test in test_datas}
53-
5453
start_time = time.time()
5554
# while there are still pending files, poll for acks and forwarded files
56-
while pending:
57-
for file_name in list(pending.keys()):
58-
test = pending[file_name]
55+
pending = True
56+
while pending and (time.time() - start_time) < max_timeout:
57+
pending = False
58+
for test_data in test_datas:
5959
# loop through keys in test (inf and bus)
60-
for key in test.keys():
61-
if test[key]:
62-
is_pending = poll_destination(file_name, key)
63-
if is_pending:
64-
test[key] = False
65-
for file_name in list(pending.keys()):
66-
test = pending[file_name]
67-
# if both inf and bus are False, remove from pending
68-
if not test[DestinationType.INF] and not test[DestinationType.BUS]:
69-
del pending[file_name]
70-
71-
# if max_timeout exceeded, break
72-
if (time.time() - start_time) > max_timeout:
73-
break
74-
60+
for ack_key in test_data.ack_keys.keys():
61+
if not test_data.ack_keys[ack_key]:
62+
found_ack_key = poll_destination(test_data.file_name, ack_key)
63+
if found_ack_key:
64+
test_data.ack_keys[ack_key] = found_ack_key
65+
else:
66+
pending = True
7567
if pending:
7668
time.sleep(1)
7769

7870
# Now validate all files have been processed correctly
79-
for test in test_datas:
71+
for test_data in test_datas:
8072
# Validate the ACK file
81-
ack_content = get_file_content_from_s3(environment.ACK_BUCKET, test.file_name)
82-
fwd_content = get_file_content_from_s3(environment.FORWARDEDFILE_BUCKET, test.fwd_key)
73+
inf_ack_content = get_file_content_from_s3(ACK_BUCKET, test_data.ack_keys[DestinationType.INF])
74+
bus_ack_content = get_file_content_from_s3(ACK_BUCKET, test_data.ack_keys[DestinationType.BUS])
8375

84-
check_ack_file_content(ack_content, "OK", None, test.action)
85-
validate_row_count(test.file_name, test.key)
86-
# Validate the forwarded file
87-
validate_row_count(test.file_name, test.key)
88-
check_ack_file_content(fwd_content, "OK", None, test.action)
76+
check_ack_file_content(inf_ack_content, "Success", None, test_data.actions)
77+
validate_row_count(test_data.file_name, test_data.ack_keys[DestinationType.BUS])
78+
# how to validate bus ack content?

e2e_batch/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
class TestData:
4545

4646
def __init__(self, description, vax_ods, actions: list, header="NHS_NUMBER",
47-
success: bool = True, dose_amount=0.5, inject_char=False, version=4,
47+
success: bool = True, dose_amount=0.5, inject_char=False, version=5,
4848
check_ack=False):
4949
self.description = description
5050
self.dose_amount = dose_amount
@@ -56,7 +56,8 @@ def __init__(self, description, vax_ods, actions: list, header="NHS_NUMBER",
5656
self.inject_char = inject_char
5757
self.version = version
5858
self.check_ack = check_ack
59-
self.file_name = None
59+
self.key = None
60+
self.ack_keys = {DestinationType.INF: None, DestinationType.BUS: None}
6061

6162

6263
def generate_csv(dose_amount, action_flag, headers="NHS_NUMBER", same_id=False, version="4",
@@ -522,7 +523,7 @@ def verify_final_ack_file(file_key):
522523
return True
523524

524525

525-
def get_file_name(vax_type, ods, version="4"):
526+
def get_file_name(vax_type, ods, version="5"):
526527
timestamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%S00")
527528
# timestamp = timestamp[:-3]
528529
if is_valid_datetime(timestamp) is False:

0 commit comments

Comments
 (0)