Skip to content

Commit 2214783

Browse files
committed
Self review
1 parent 9a86026 commit 2214783

5 files changed

Lines changed: 18 additions & 13 deletions

File tree

lambdas/backend/src/filter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Functions for filtering a FHIR Immunization Resource"""
22

3+
import copy
4+
35
from common.models.constants import Constants, Urls
46
from common.models.utils.generic_utils import (
57
get_contained_patient,
@@ -36,7 +38,7 @@ def create_reference_to_patient_resource(patient_full_url: str, patient: dict) -
3638

3739
for identifier in patient.get("identifier", []):
3840
if identifier.get("system", "") == Urls.NHS_NUMBER:
39-
patient_nhs_number_identifier = identifier
41+
patient_nhs_number_identifier = copy.deepcopy(identifier)
4042
break
4143

4244
if patient_nhs_number_identifier is None:

lambdas/backend/tests/test_filter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def test_create_reference_to_patient_resource_when_identifier_missing(self):
101101
)
102102

103103
def test_create_reference_to_patient_resource_when_nhs_number_missing(self):
104-
"""Test that create_reference_to_patient_resource creates an appropriate reference with empty identifier info
105-
where the saved patient record does not contain this information"""
104+
"""Test that create_reference_to_patient_resource creates an appropriate reference with empty
105+
identifier[0].value info where the saved patient record does not contain this information"""
106106
test_data = deepcopy(self.bundle_patient_resource)
107107
del test_data["identifier"][0]["value"]
108108

lambdas/shared/tests/test_common/testing_utils/immunization_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from fhir.resources.R4B.immunization import Immunization
44

5+
from common.models.constants import Constants
56
from test_common.testing_utils.generic_utils import load_json_data
67
from test_common.testing_utils.values_for_tests import ValidValues
78

@@ -24,7 +25,7 @@ def create_covid_immunization_dict(
2425
immunization_json["id"] = imms_id
2526

2627
for contained_resource in immunization_json.get("contained", []):
27-
if contained_resource.get("resourceType") == "Patient":
28+
if contained_resource.get("resourceType") == Constants.PATIENT_RESOURCE_TYPE:
2829
if omit_nhs_number:
2930
del contained_resource["identifier"][0]["value"]
3031
else:

tests/e2e_automation/features/APITests/search.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,22 +201,22 @@ Feature: Search the immunization of a patient
201201
@Delete_cleanUp @vaccine_type_FLU @patient_id_Random @supplier_name_Postman_Auth
202202
Scenario: Flu event is created and search post request fetch the only one record matched with identifier
203203
Given I have created a valid vaccination record
204-
When Send a search request with Post method using identifier parameter for Immunization event created
204+
When I send a search request with Post method using identifier parameter for Immunization event created
205205
Then The request will be successful with the status code '200'
206206
And correct immunization event is returned in the response
207207

208208
@smoke
209209
@Delete_cleanUp @vaccine_type_FLU @patient_id_NullNHS @supplier_name_Postman_Auth
210210
Scenario: Search by Identifier (POST) is successful when patient does not have an NHS Number recorded
211211
Given I have created a valid vaccination record
212-
When Send a search request with Post method using identifier parameter for Immunization event created
212+
When I send a search request with Post method using identifier parameter for Immunization event created
213213
Then The request will be successful with the status code '200'
214214
And correct immunization event is returned in the response
215215

216216
@Delete_cleanUp @vaccine_type_FLU @patient_id_Random @supplier_name_Postman_Auth
217217
Scenario: Flu event is created and search post request fetch the only one record matched with identifier and _elements
218218
Given I have created a valid vaccination record
219-
When Send a search request with Post method using identifier and _elements parameters for Immunization event created
219+
When I send a search request with Post method using identifier and _elements parameters for Immunization event created
220220
Then The request will be successful with the status code '200'
221221
And correct immunization event is returned in the response with only specified elements
222222

@@ -225,7 +225,7 @@ Feature: Search the immunization of a patient
225225
Scenario: Flu event is created and search post request fetch the only one record matched with identifier with correct version id
226226
Given I have created a valid vaccination record
227227
And created event is being updated twice
228-
When Send a search request with Post method using identifier parameter for Immunization event created
228+
When I send a search request with Post method using identifier parameter for Immunization event created
229229
Then The request will be successful with the status code '200'
230230
And correct immunization event is returned in the response
231231

@@ -234,13 +234,13 @@ Feature: Search the immunization of a patient
234234
Scenario: Flu event is created and search post request fetch the only one record matched with identifier and _elements with correct version id
235235
Given I have created a valid vaccination record
236236
And created event is being updated twice
237-
When Send a search request with Post method using identifier and _elements parameters for Immunization event created
237+
When I send a search request with Post method using identifier and _elements parameters for Immunization event created
238238
Then The request will be successful with the status code '200'
239239
And correct immunization event is returned in the response with only specified elements
240240

241241
@smoke
242242
@vaccine_type_4IN1 @patient_id_Random @supplier_name_Postman_Auth
243243
Scenario: Empty search response will be received when no record is found for the given identifier in search request
244-
When Send a search request with post method using invalid identifier header for Immunization event created
244+
When I send a search request with Post method using an invalid identifier header for Immunization event created
245245
Then The request will be successful with the status code '200'
246246
And Empty immunization event is returned in the response

tests/e2e_automation/features/APITests/steps/test_search_steps.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
scenarios("APITests/search.feature")
2121

2222

23-
@when("Send a search request with Post method using identifier parameter for Immunization event created")
23+
@when("I send a search request with Post method using identifier parameter for Immunization event created")
2424
def send_search_post_request_with_identifier_header(context):
2525
get_search_post_url_header(context)
2626
context.request = {
@@ -30,7 +30,9 @@ def send_search_post_request_with_identifier_header(context):
3030
context.response = http_requests_session.post(context.url, headers=context.headers, data=context.request)
3131

3232

33-
@when("Send a search request with Post method using identifier and _elements parameters for Immunization event created")
33+
@when(
34+
"I send a search request with Post method using identifier and _elements parameters for Immunization event created"
35+
)
3436
def send_search_post_request_with_identifier_and_elements_header(context):
3537
get_search_post_url_header(context)
3638
context.request = {
@@ -41,7 +43,7 @@ def send_search_post_request_with_identifier_and_elements_header(context):
4143
context.response = http_requests_session.post(context.url, headers=context.headers, data=context.request)
4244

4345

44-
@when("Send a search request with post method using invalid identifier header for Immunization event created")
46+
@when("I send a search request with Post method using an invalid identifier header for Immunization event created")
4547
def send_search_post_request_with_invalid_identifier_header(context):
4648
get_search_post_url_header(context)
4749
context.request = {"identifier": f"https://www.ieds.england.nhs.uk/|{str(uuid.uuid4())}", "_elements": "meta,id"}

0 commit comments

Comments
 (0)