Skip to content

Commit fff3f66

Browse files
authored
Feature/ved 1106 (#1280)
* fix the broken test * fix search broken tests * added missing option for batch file validation scenarios * fix
1 parent 7ec3f08 commit fff3f66

6 files changed

Lines changed: 93 additions & 132 deletions

File tree

.github/workflows/run-e2e-automation-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ on:
6767
- functional
6868
- sandbox
6969
- proxy_smoke
70+
- Batch_File_Validation_Feature
7071

7172
env:
7273
APIGEE_AUTH_ENV: ${{ inputs.apigee_environment == 'int' && inputs.apigee_environment || 'internal-dev' }}

tests/e2e_automation/features/APITests/search.feature

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,14 @@ Feature: Search the immunization of a patient
272272
@Delete_cleanUp @supplier_name_TPP
273273
Scenario: Verify that Search API returns immunization events when searching by target-disease (GET)
274274
Given Valid vaccination record is created with Patient 'Random' and vaccine_type 'MMRV'
275-
When Send a search request with GET method using target-disease for Immunization event created
275+
When Send a search request with 'GET' method using target-disease for Immunization event created
276276
Then The request will be successful with the status code '200'
277277
And The Search Response JSONs should contain the detail of the immunization events created above
278278

279279
@Delete_cleanUp @supplier_name_EMIS
280280
Scenario: Verify that Search API returns immunization events when searching by target-disease (POST)
281281
Given Valid vaccination record is created with Patient 'Random' and vaccine_type '3IN1'
282-
When Send a search request with POST method using target-disease for Immunization event created
282+
When Send a search request with 'POST' method using target-disease for Immunization event created
283283
Then The request will be successful with the status code '200'
284284
And The Search Response JSONs should contain the detail of the immunization events created above
285285

@@ -304,14 +304,14 @@ Feature: Search the immunization of a patient
304304
@Delete_cleanUp @supplier_name_Postman_Auth
305305
Scenario: Verify that Search API returns immunization events when searching by comma-separated target-disease (GET)
306306
Given Valid vaccination record is created with Patient 'Random' and vaccine_type 'HEPB'
307-
When Send a search request with GET method using comma-separated target-disease for Immunization event created
307+
When Send a search request with 'GET' method using comma-separated target-disease for Immunization event created
308308
Then The request will be successful with the status code '200'
309309
And The Search Response JSONs should contain the detail of the immunization events created above
310310

311311
@Delete_cleanUp @supplier_name_Postman_Auth
312312
Scenario: Verify that Search API returns immunization events when searching by comma-separated target-disease (POST)
313313
Given Valid vaccination record is created with Patient 'Random' and vaccine_type 'COVID'
314-
When Send a search request with POST method using comma-separated target-disease for Immunization event created
314+
When Send a search request with 'POST' method using comma-separated target-disease for Immunization event created
315315
Then The request will be successful with the status code '200'
316316
And The Search Response JSONs should contain the detail of the immunization events created above
317317

@@ -334,20 +334,20 @@ Feature: Search the immunization of a patient
334334

335335
@supplier_name_Postman_Auth
336336
Scenario: Verify that Search API returns 400 when all target-disease values are invalid SNOMED codes
337-
When Send a search request with GET method with valid NHS Number and all invalid target-disease codes
337+
When Send a search request with 'GET' method with valid NHS Number and all invalid target-disease codes
338338
Then The request will be unsuccessful with the status code '400'
339339
And The Response JSONs should contain correct error message for invalid target-disease codes
340-
When Send a search request with POST method with valid NHS Number and all invalid target-disease codes
340+
When Send a search request with 'POST' method with valid NHS Number and all invalid target-disease codes
341341
Then The request will be unsuccessful with the status code '400'
342342
And The Response JSONs should contain correct error message for invalid target-disease codes
343343

344344
@smoke
345345
@Delete_cleanUp @supplier_name_Postman_Auth
346346
Scenario: Verify that Search API returns 200 with results and OperationOutcome when some target-disease values are invalid
347347
Given Valid vaccination record is created with Patient 'Random' and vaccine_type '6IN1'
348-
When Send a search request with GET method using mixed valid and invalid target-disease codes for Immunization event created
348+
When Send a search request with 'GET' method using mixed valid and invalid target-disease codes for Immunization event created
349349
Then The request will be successful with the status code '200'
350350
And The Search Response should contain search results and OperationOutcome for invalid target-disease codes
351-
When Send a search request with POST method using mixed valid and invalid target-disease codes for Immunization event created
351+
When Send a search request with 'POST' method using mixed valid and invalid target-disease codes for Immunization event created
352352
Then The request will be successful with the status code '200'
353353
And The Search Response should contain search results and OperationOutcome for invalid target-disease codes

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

Lines changed: 40 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
validate_error_response,
1414
validate_to_compare_request_and_response,
1515
)
16-
from utilities.api_get_header import get_search_get_url_header, get_search_post_url_header
16+
from utilities.api_get_header import (
17+
get_search_get_url_header,
18+
get_search_post_url_header,
19+
)
1720
from utilities.date_helper import iso_to_compact
1821
from utilities.http_requests_session import http_requests_session
1922

@@ -66,78 +69,51 @@ def trigger_search_request(context, httpMethod):
6669
trigger_search_request_by_httpMethod(context, httpMethod=httpMethod)
6770

6871

69-
@when("Send a search request with GET method using target-disease for Immunization event created")
70-
def send_search_get_with_target_disease(context):
71-
get_search_get_url_header(context)
72-
patient_ident = context.create_object.contained[1].identifier[0]
73-
target = context.create_object.protocolApplied[0].targetDisease[0].coding[0]
74-
context.params = {
75-
"patient.identifier": f"{patient_ident.system}|{patient_ident.value}",
76-
"target-disease": f"{target.system}|{target.code}",
77-
}
78-
print(f"\n Search Get parameters (target-disease) - \n {context.params}")
79-
context.response = http_requests_session.get(context.url, params=context.params, headers=context.headers)
80-
81-
8272
@when("Send a search request with POST method for Immunization event created")
8373
def TriggerSearchPostRequest(context):
84-
get_search_post_url_header(context)
8574
context.request = convert_to_form_data(
8675
set_request_data(
87-
context.patient.identifier[0].value, context.vaccine_type, datetime.today().strftime("%Y-%m-%d")
76+
context.patient.identifier[0].value,
77+
context.vaccine_type,
78+
datetime.today().strftime("%Y-%m-%d"),
8879
)
8980
)
90-
print(f"\n Search Post Request - \n {context.request}")
91-
context.response = http_requests_session.post(context.url, headers=context.headers, data=context.request)
92-
print(f"\n Search Post Response - \n {context.response.json()}")
81+
trigger_search_request_by_httpMethod(context, httpMethod="POST")
9382

9483

95-
@when("Send a search request with POST method using target-disease for Immunization event created")
96-
def send_search_post_with_target_disease(context):
97-
get_search_post_url_header(context)
84+
@when(
85+
parsers.parse("Send a search request with '{httpMethod}' method using target-disease for Immunization event created")
86+
)
87+
def send_search_with_target_disease(context, httpMethod):
9888
patient_ident = context.create_object.contained[1].identifier[0]
9989
target = context.create_object.protocolApplied[0].targetDisease[0].coding[0]
100-
context.request = {
90+
context.params = context.request = {
10191
"patient.identifier": f"{patient_ident.system}|{patient_ident.value}",
10292
"target-disease": f"{target.system}|{target.code}",
10393
}
104-
print(f"\n Search Post request (target-disease) - \n {context.request}")
105-
context.response = http_requests_session.post(context.url, headers=context.headers, data=context.request)
106-
107-
108-
@when("Send a search request with GET method using comma-separated target-disease for Immunization event created")
109-
def send_search_get_with_comma_separated_target_disease(context):
110-
get_search_get_url_header(context)
111-
patient_ident = context.create_object.contained[1].identifier[0]
112-
targets = context.create_object.protocolApplied[0].targetDisease
113-
target_parts = [f"{t.coding[0].system}|{t.coding[0].code}" for t in targets[:2]]
114-
context.params = {
115-
"patient.identifier": f"{patient_ident.system}|{patient_ident.value}",
116-
"target-disease": ",".join(target_parts),
117-
}
118-
print(f"\n Search Get parameters (comma-separated target-disease) - \n {context.params}")
119-
context.response = http_requests_session.get(context.url, params=context.params, headers=context.headers)
94+
trigger_search_request_by_httpMethod(context, httpMethod=httpMethod)
12095

12196

122-
@when("Send a search request with POST method using comma-separated target-disease for Immunization event created")
123-
def send_search_post_with_comma_separated_target_disease(context):
124-
get_search_post_url_header(context)
97+
@when(
98+
parsers.parse(
99+
"Send a search request with '{httpMethod}' method using comma-separated target-disease for Immunization event created"
100+
)
101+
)
102+
def send_search_post_with_comma_separated_target_disease(context, httpMethod):
125103
patient_ident = context.create_object.contained[1].identifier[0]
126104
targets = context.create_object.protocolApplied[0].targetDisease
127105
target_parts = [f"{t.coding[0].system}|{t.coding[0].code}" for t in targets[:2]]
128-
context.request = {
106+
context.params = context.request = {
129107
"patient.identifier": f"{patient_ident.system}|{patient_ident.value}",
130108
"target-disease": ",".join(target_parts),
131109
}
132-
print(f"\n Search Post request (comma-separated target-disease) - \n {context.request}")
133-
context.response = http_requests_session.post(context.url, headers=context.headers, data=context.request)
110+
trigger_search_request_by_httpMethod(context, httpMethod=httpMethod)
134111

135112

136113
@when(
137114
"Send a search request with GET method using target-disease and Date From and Date To for Immunization event created"
138115
)
139116
def send_search_get_with_target_disease_and_dates(context):
140-
get_search_get_url_header(context)
141117
patient_ident = context.create_object.contained[1].identifier[0]
142118
target = context.create_object.protocolApplied[0].targetDisease[0].coding[0]
143119
context.DateFrom = "2023-01-01"
@@ -148,15 +124,13 @@ def send_search_get_with_target_disease_and_dates(context):
148124
"-date.from": context.DateFrom,
149125
"-date.to": context.DateTo,
150126
}
151-
print(f"\n Search Get parameters (target-disease with dates) - \n {context.params}")
152-
context.response = http_requests_session.get(context.url, params=context.params, headers=context.headers)
127+
trigger_search_request_by_httpMethod(context, httpMethod="GET")
153128

154129

155130
@when(
156131
"Send a search request with POST method using target-disease and Date From and Date To for Immunization event created"
157132
)
158133
def send_search_post_with_target_disease_and_dates(context):
159-
get_search_post_url_header(context)
160134
patient_ident = context.create_object.contained[1].identifier[0]
161135
target = context.create_object.protocolApplied[0].targetDisease[0].coding[0]
162136
context.DateFrom = "2023-01-01"
@@ -167,72 +141,45 @@ def send_search_post_with_target_disease_and_dates(context):
167141
"-date.from": context.DateFrom,
168142
"-date.to": context.DateTo,
169143
}
170-
print(f"\n Search Post request (target-disease with dates) - \n {context.request}")
171-
context.response = http_requests_session.post(context.url, headers=context.headers, data=context.request)
144+
trigger_search_request_by_httpMethod(context, httpMethod="POST")
172145

173146

174147
@when("Send a search request with GET method using target-disease for Immunization event created with valid NHS Number")
175148
def send_search_get_with_target_disease_unauthorised_supplier(context):
176-
get_search_get_url_header(context)
177149
nhs_number = "9000000009"
178150
context.params = {
179151
"patient.identifier": f"{PATIENT_IDENTIFIER_SYSTEM}|{nhs_number}",
180152
"target-disease": f"{TARGET_DISEASE_SYSTEM}|14189004",
181153
}
182-
print(f"\n Search Get parameters (target-disease, 403 check) - \n {context.params}")
183-
context.response = http_requests_session.get(context.url, params=context.params, headers=context.headers)
184-
185-
186-
@when("Send a search request with GET method with valid NHS Number and all invalid target-disease codes")
187-
def send_search_get_with_all_invalid_target_disease_codes(context):
188-
get_search_get_url_header(context)
189-
context.params = {
190-
"patient.identifier": f"{PATIENT_IDENTIFIER_SYSTEM}|9000000009",
191-
"target-disease": "invalid-no-pipe,wrong_system|123",
192-
}
193-
print(f"\n Search Get parameters (all invalid target-disease) - \n {context.params}")
194-
context.response = http_requests_session.get(context.url, params=context.params, headers=context.headers)
195-
196-
197-
@when("Send a search request with POST method with valid NHS Number and all invalid target-disease codes")
198-
def send_search_post_with_all_invalid_target_disease_codes(context):
199-
get_search_post_url_header(context)
200-
context.request = {
201-
"patient.identifier": f"{PATIENT_IDENTIFIER_SYSTEM}|9000000009",
202-
"target-disease": "invalid-no-pipe,wrong_system|123",
203-
}
204-
print(f"\n Search Post request (all invalid target-disease) - \n {context.request}")
205-
context.response = http_requests_session.post(context.url, headers=context.headers, data=context.request)
154+
trigger_search_request_by_httpMethod(context, httpMethod="GET")
206155

207156

208157
@when(
209-
"Send a search request with GET method using mixed valid and invalid target-disease codes for Immunization event created"
158+
parsers.parse(
159+
"Send a search request with '{httpMethod}' method with valid NHS Number and all invalid target-disease codes"
160+
)
210161
)
211-
def send_search_get_with_mixed_valid_and_invalid_target_disease_codes(context):
212-
get_search_get_url_header(context)
213-
patient_ident = context.create_object.contained[1].identifier[0]
214-
target = context.create_object.protocolApplied[0].targetDisease[0].coding[0]
215-
context.params = {
216-
"patient.identifier": f"{patient_ident.system}|{patient_ident.value}",
217-
"target-disease": f"{target.system}|{target.code},{TARGET_DISEASE_SYSTEM}|{INVALID_TARGET_DISEASE_CODE}",
162+
def send_search_request_with_all_invalid_target_disease_codes(context, httpMethod):
163+
context.params = context.request = {
164+
"patient.identifier": f"{PATIENT_IDENTIFIER_SYSTEM}|9000000009",
165+
"target-disease": "invalid-no-pipe,wrong_system|123",
218166
}
219-
print(f"\n Search Get parameters (mixed valid/invalid target-disease) - \n {context.params}")
220-
context.response = http_requests_session.get(context.url, params=context.params, headers=context.headers)
167+
trigger_search_request_by_httpMethod(context, httpMethod=httpMethod)
221168

222169

223170
@when(
224-
"Send a search request with POST method using mixed valid and invalid target-disease codes for Immunization event created"
171+
parsers.parse(
172+
"Send a search request with '{httpMethod}' method using mixed valid and invalid target-disease codes for Immunization event created"
173+
)
225174
)
226-
def send_search_post_with_mixed_valid_and_invalid_target_disease_codes(context):
227-
get_search_post_url_header(context)
175+
def send_search_post_with_mixed_valid_and_invalid_target_disease_codes(context, httpMethod):
228176
patient_ident = context.create_object.contained[1].identifier[0]
229177
target = context.create_object.protocolApplied[0].targetDisease[0].coding[0]
230-
context.request = {
178+
context.params = context.request = {
231179
"patient.identifier": f"{patient_ident.system}|{patient_ident.value}",
232180
"target-disease": f"{target.system}|{target.code},{TARGET_DISEASE_SYSTEM}|{INVALID_TARGET_DISEASE_CODE}",
233181
}
234-
print(f"\n Search Post request (mixed valid/invalid target-disease) - \n {context.request}")
235-
context.response = http_requests_session.post(context.url, headers=context.headers, data=context.request)
182+
trigger_search_request_by_httpMethod(context, httpMethod=httpMethod)
236183

237184

238185
@when(
@@ -284,16 +231,14 @@ def send_search_with_target_disease_and_immunization_target(context, httpMethod)
284231

285232
@when("Send a search request with GET method using target-disease and identifier for Immunization event created")
286233
def send_search_get_with_target_disease_and_identifier(context):
287-
get_search_get_url_header(context)
288234
patient_ident = context.create_object.contained[1].identifier[0]
289235
target = context.create_object.protocolApplied[0].targetDisease[0].coding[0]
290236
context.params = {
291237
"patient.identifier": f"{patient_ident.system}|{patient_ident.value}",
292238
"target-disease": f"{target.system}|{target.code}",
293239
"identifier": "https://example.org|abc-123",
294240
}
295-
print(f"\n Search Get parameters (target-disease with identifier) - \n {context.params}")
296-
context.response = http_requests_session.get(context.url, params=context.params, headers=context.headers)
241+
trigger_search_request_by_httpMethod(context, httpMethod="GET")
297242

298243

299244
@when(

tests/e2e_automation/features/batchTests/Steps/test_batch_file_validation_steps.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
from utilities.batch_file_helper import validate_inf_ack_file
1010
from utilities.batch_S3_buckets import wait_and_read_ack_file
1111

12-
from .batch_common_steps import build_dataFrame_using_datatable, create_batch_file, ignore_if_local_run
12+
from .batch_common_steps import (
13+
build_dataFrame_using_datatable,
14+
create_batch_file,
15+
ignore_if_local_run,
16+
)
1317

1418
scenarios("batchTests/batch_file_validation.feature")
1519

@@ -77,7 +81,7 @@ def batch_file_with_additional_column_is_created(datatable, context):
7781
def file_will_be_moved_to_destination_bucket(context):
7882
result = wait_and_read_ack_file(context, "ack", duplicate_inf_files=True)
7983
assert result is not None, f"File not found in destination bucket after timeout: {context.forwarded_prefix}"
80-
context.fileContent = result["csv"]
84+
context.fileContent = result["csv"]["content"]
8185
assert context.fileContent, f"File not found in destination bucket after timeout: {context.forwarded_prefix}"
8286

8387

0 commit comments

Comments
 (0)