Skip to content

Commit 788408a

Browse files
committed
Unit Tests Pass
1 parent dc5b8c8 commit 788408a

File tree

2 files changed

+3
-214
lines changed

2 files changed

+3
-214
lines changed

delta_backend/tests/test_delta.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -53,51 +53,6 @@ def setUp_mock_resources(self, mock_boto_resource, mock_boto_client):
5353
mock_table.put_item.side_effect = Exception("Test Exception")
5454
return mock_table
5555

56-
# @staticmethod
57-
# def get_event(event_name="INSERT", operation="CREATE", supplier="EMIS", n_records=1):
58-
# """Create test event for the handler function."""
59-
# return {
60-
# "Records": [
61-
# DeltaTestCase.get_event_record(f"covid#{i+1}2345", event_name, operation, supplier)
62-
# for i in range(n_records)
63-
# ]
64-
# }
65-
66-
# @staticmethod
67-
# def get_event_record(pk, event_name="INSERT", operation="CREATE", supplier="EMIS"):
68-
# if operation != "DELETE":
69-
# return{
70-
# "eventName": event_name,
71-
# "dynamodb": {
72-
# "ApproximateCreationDateTime": 1690896000,
73-
# "NewImage": {
74-
# "PK": {"S": pk},
75-
# "PatientSK": {"S": pk},
76-
# "IdentifierPK": {"S": "system#1"},
77-
# "Operation": {"S": operation},
78-
# "SupplierSystem": {"S": supplier},
79-
# "Resource": {
80-
# "S": json.dumps(ValuesForTests.get_test_data_resource()),
81-
# }
82-
# }
83-
# }
84-
# }
85-
# else:
86-
# return {
87-
# "eventName": "REMOVE",
88-
# "dynamodb": {
89-
# "ApproximateCreationDateTime": 1690896000,
90-
# "Keys": {
91-
# "PK": {"S": pk},
92-
# "PatientSK": {"S": pk},
93-
# "SupplierSystem": {"S": "EMIS"},
94-
# "Resource": {
95-
# "S": json.dumps(ValuesForTests.get_test_data_resource()),
96-
# }
97-
# }
98-
# }
99-
# }
100-
10156
@patch("boto3.client")
10257
def test_send_message_success(self, mock_boto_client):
10358
# Arrange

delta_backend/tests/utils_for_converter_tests.py

Lines changed: 3 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ def get_event_record(imms_id, event_name, operation, supplier="EMIS"):
171171
"IdentifierPK": {"S": "system#1"},
172172
"Operation": {"S": operation},
173173
"SupplierSystem": {"S": supplier},
174-
"Resource": {
175-
"S": json.dumps(ValuesForTests.get_test_data_resource()),
176-
}
174+
"Resource": {"S": ValuesForTests.json_value_for_test},
177175
}
178176
}
179177
}
@@ -186,9 +184,7 @@ def get_event_record(imms_id, event_name, operation, supplier="EMIS"):
186184
"PK": {"S": pk},
187185
"PatientSK": {"S": "COVID19#ca8ba2c6-2383-4465-b456-c1174c21cf31"},
188186
"SupplierSystem": {"S": supplier},
189-
"Resource": {
190-
"S": json.dumps(ValuesForTests.get_test_data_resource()),
191-
}
187+
"Resource": {"S": ValuesForTests.json_value_for_test},
192188
}
193189
}
194190
}
@@ -209,7 +205,7 @@ def get_expected_imms(expected_action_flag):
209205
"PERSON_SURNAME": "Trailor",
210206
"PERSON_DOB": "19650228",
211207
"PERSON_GENDER_CODE": "0",
212-
"PERSON_POSTCODE": "EC1A 1BB-2",
208+
"PERSON_POSTCODE": "EC1A 1BB",
213209
"DATE_AND_TIME": "20210207T13281700",
214210
"SITE_CODE": "B0C4P",
215211
"SITE_CODE_TYPE_URI": "https://fhir.nhs.uk/Id/ods-organization-code",
@@ -316,168 +312,6 @@ def get_expected_imms(expected_action_flag):
316312
"LOCATION_CODE_TYPE_URI": "https://fhir.nhs.uk/Id/ods-organization-code",
317313
"CONVERSION_ERRORS": []
318314
}
319-
320-
@staticmethod
321-
def get_test_data_resource():
322-
"""
323-
The returned resource includes details about the practitioner, patient,
324-
vaccine code, location, and other relevant fields.
325-
"""
326-
return {
327-
"resourceType": "Immunization",
328-
"contained": [
329-
{
330-
"resourceType": "Practitioner",
331-
"id": "Pract1",
332-
"name": [
333-
{
334-
"family": "O'Reilly",
335-
"given": ["Ellena"]
336-
}
337-
]
338-
},
339-
{
340-
"resourceType": "Patient",
341-
"id": "Pat1",
342-
"identifier": [
343-
{
344-
"system": "https://fhir.nhs.uk/Id/nhs-number",
345-
"value": "9674963871"
346-
}
347-
],
348-
"name": [
349-
{
350-
"family": "GREIR",
351-
"given": ["SABINA"]
352-
}
353-
],
354-
"gender": "female",
355-
"birthDate": "2019-01-31",
356-
"address": [
357-
{
358-
"postalCode": "GU14 6TU-1"
359-
}
360-
]
361-
}
362-
],
363-
"extension": [
364-
{
365-
"url": "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-VaccinationProcedure",
366-
"valueCodeableConcept": {
367-
"coding": [
368-
{
369-
"system": "http://snomed.info/sct",
370-
"code": "1303503001",
371-
"display":
372-
"Administration of vaccine product containing only Human orthopneumovirus antigen (procedure)"
373-
}
374-
]
375-
}
376-
}
377-
],
378-
"identifier": [
379-
{
380-
"system": "https://www.ravs.england.nhs.uk/",
381-
"value": "0001_RSV_v5_RUN_2_CDFDPS-742_valid_dose_1"
382-
}
383-
],
384-
"status": "completed",
385-
"vaccineCode": {
386-
"coding": [
387-
{
388-
"system": "http://snomed.info/sct",
389-
"code": "42605811000001109",
390-
"display":
391-
"Abrysvo vaccine powder and solvent for solution for injection 0.5ml vials (Pfizer Ltd) (product)"
392-
}
393-
]
394-
},
395-
"patient": {
396-
"reference": "#Pat1"
397-
},
398-
"occurrenceDateTime": "2024-06-10T18:33:25+00:00",
399-
"recorded": "2024-06-10T18:33:25+00:00",
400-
"primarySource": True,
401-
"manufacturer": {
402-
"display": "Pfizer"
403-
},
404-
"location": {
405-
"type": "Location",
406-
"identifier": {
407-
"value": "J82067",
408-
"system": "https://fhir.nhs.uk/Id/ods-organization-code"
409-
}
410-
},
411-
"lotNumber": "RSVTEST",
412-
"expirationDate": "2024-12-31",
413-
"site": {
414-
"coding": [
415-
{
416-
"system": "http://snomed.info/sct",
417-
"code": "368208006",
418-
"display": "Left upper arm structure (body structure)"
419-
}
420-
]
421-
},
422-
"route": {
423-
"coding": [
424-
{
425-
"system": "http://snomed.info/sct",
426-
"code": "78421000",
427-
"display": "Intramuscular route (qualifier value)"
428-
}
429-
]
430-
},
431-
"doseQuantity": {
432-
"value": 0.5,
433-
"unit": "Milliliter (qualifier value)",
434-
"system": "http://unitsofmeasure.org",
435-
"code": "258773002"
436-
},
437-
"performer": [
438-
{
439-
"actor": {
440-
"reference": "#Pract1"
441-
}
442-
},
443-
{
444-
"actor": {
445-
"type": "Organization",
446-
"identifier": {
447-
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
448-
"value": "X0X0X"
449-
}
450-
}
451-
}
452-
],
453-
"reasonCode": [
454-
{
455-
"coding": [
456-
{
457-
"code": "Test",
458-
"system": "http://snomed.info/sct"
459-
}
460-
]
461-
}
462-
],
463-
"protocolApplied": [
464-
{
465-
"targetDisease": [
466-
{
467-
"coding": [
468-
{
469-
"system": "http://snomed.info/sct",
470-
"code": "840539006",
471-
"display": "Disease caused by severe acute respiratory syndrome coronavirus 2"
472-
}
473-
]
474-
}
475-
],
476-
"doseNumberPositiveInt": 1
477-
}
478-
],
479-
"id": "ca8ba2c6-2383-4465-b456-c1174c21cf31"
480-
}
481315

482316

483317
class ErrorValuesForTests:

0 commit comments

Comments
 (0)