Skip to content

Commit 59b8a96

Browse files
committed
Finalised manual upload tests
1 parent c14911f commit 59b8a96

4 files changed

Lines changed: 72 additions & 4 deletions

File tree

scripts/manual_uploads/manual_s3_dynamo_upload.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def upload_to_s3(
4343
) -> None:
4444

4545
filename = os.path.basename(filepath)
46-
print(f"Filepath: {filepath}")
4746
s3_key = f"manual-uploads/{filename}"
4847

4948
if dry_run:
@@ -98,11 +97,23 @@ def run_upload(args: Optional[List[str]] = None) -> None:
9897
dynamo = session.client("dynamodb", region_name=parsed_args.region)
9998

10099
if parsed_args.upload_s3:
101-
for filepath in parsed_args.upload_s3.glob("*.json"):
100+
if parsed_args.upload_s3.is_dir():
101+
files = parsed_args.upload_s3.glob("*.json")
102+
else:
103+
files = [parsed_args.upload_s3]
104+
105+
for filepath in files:
106+
print(f"Uploading to S3 from {filepath}")
102107
upload_to_s3(s3, parsed_args.s3_bucket, str(filepath), parsed_args.dry_run)
103108

104109
if parsed_args.upload_dynamo:
105-
for filepath in parsed_args.upload_dynamo.glob("*.json"):
110+
if parsed_args.upload_dynamo.is_dir():
111+
paths = parsed_args.upload_dynamo.glob("*.json")
112+
else:
113+
paths = [parsed_args.upload_dynamo]
114+
115+
for filepath in paths:
116+
print(f"Uploading to DynamoDB from {filepath}")
106117
upload_to_dynamo(dynamo, parsed_args.dynamo_table, str(filepath))
107118

108119

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"CampaignConfig": {
3+
"ID": "id_1",
4+
"Version": 1,
5+
"Name": "Test Config",
6+
"Type": "V",
7+
"Target": "COVID",
8+
"Manager": "person@test.com",
9+
"Approver": "person@test.com",
10+
"Reviewer": "person@test.com",
11+
"IterationFrequency": "X",
12+
"IterationType": "M",
13+
"IterationTime": "07:00:00",
14+
"DefaultCommsRouting": "Default_Comms_1",
15+
"Iterations": [
16+
{
17+
"ID": "id_1",
18+
"DefaultCommsRouting": "Default_Comms_1",
19+
"IterationCohorts": [
20+
{
21+
"CohortLabel": "cohort_1",
22+
"Priority": 10
23+
},
24+
{
25+
"CohortLabel": "cohort_2",
26+
"Priority": 20
27+
}
28+
],
29+
"IterationRules": [
30+
{
31+
"Type": "F",
32+
"Name": "Test Rule",
33+
"Description": "Test Rule Desc",
34+
"Priority": 20,
35+
"AttributeLevel": "PERSON",
36+
"AttributeName": "DATE_OF_BIRTH",
37+
"Operator": ">",
38+
"Comparator": "19000101"
39+
}
40+
],
41+
"Version": 1,
42+
"Name": "Test Config",
43+
"Type": "M",
44+
"IterationDate": "20250101",
45+
"IterationNumber": 1,
46+
"CommsType": "R",
47+
"ApprovalMinimum": 1,
48+
"ApprovalMaximum": 5000000
49+
}
50+
],
51+
"StartDate": "20250101",
52+
"EndDate": "20250101",
53+
"ApprovalMinimum": 1,
54+
"ApprovalMaximum": 5000000
55+
}
56+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{"NHS_NUMBER": "1234567890", "ATTRIBUTE_TYPE": "COHORTS", "COHORT_MEMBERSHIPS": [{"COHORT_LABEL": "under_75", "DATE_JOINED": "2025-01-01"},{"COHORT_LABEL": "over_75", "DATE_JOINED": "2025-01-01"}]}
2+
{"NHS_NUMBER": "2345678901", "ATTRIBUTE_TYPE": "COHORTS", "COHORT_MEMBERSHIPS": [{"COHORT_LABEL": "under_75", "DATE_JOINED": "2025-01-01"},{"COHORT_LABEL": "over_75", "DATE_JOINED": "2025-01-01"}]}

tests/utils/manual_s3_dynamo_upload_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def test_script_cli_end_to_end(test_data_dir):
7878
}
7979
response = dynamodb.get_item(TableName=dynamo_table, Key=key)
8080
item = response.get("Item")
81-
assert item is not None, f"Missing item for key {key}"
8281
dynamo_items.append(item)
8382

8483
expected_dynamo_items = [{k: map_dynamo_type(v) for k, v in item.items()} for item in expected_data]

0 commit comments

Comments
 (0)