Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(testing):#370 added tavern tests for auditContractNegotiation #760

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions local/testing/api-tests/irs-api-tests.tavern.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3200,5 +3200,119 @@ stages:
status_code: 200
verify_response_with:
function: local.testing.api-tests.tavern_helpers:check_batches_are_canceled_correctly
headers:
content-type: application/json


---


test_name: Make sure jobs are responsed with contractAgreementIds in shells and submodels if auditContractNegotiation activated

strict:
- headers:off
- json:off

stages:
- name: create a job and check for success
request:
url: "{tavern.env_vars.IRS_HOST}/irs/jobs"
json:
key:
globalAssetId: "{tavern.env_vars.GLOBAL_ASSET_ID_AS_BUILT}"
bpn: "{tavern.env_vars.BPN_AS_BUILT}"
collectAspects: true
auditContractNegotiation: true
depth: 2
aspects:
- SerialPart
direction: "downward"
method: POST
headers:
content-type: application/json
$ext:
function: local.testing.api-tests.tavern_helpers:create_api_key
response:
status_code: 201
headers:
content-type: application/json
save:
json:
job_id: id

- *verify_job_is_running_and_wait_up_to_15_minutes_for_COMPLETED

- name: verify job response with desired test steps
request:
url: "{tavern.env_vars.IRS_HOST}/irs/jobs/{job_id}"
params:
returnUncompletedJob: true
method: GET
headers:
content-type: application/json
$ext:
function: local.testing.api-tests.tavern_helpers:create_api_key
response:
status_code: 200
verify_response_with:
- function: local.testing.api-tests.tavern_helpers:contractAgreementId_in_shells_existing
- function: local.testing.api-tests.tavern_helpers:contractAgreementId_in_submodels_existing
headers:
content-type: application/json


---


test_name: Make sure jobs are not responsed with contractAgreementIds in shells and submodels if auditContractNegotiation deactivated

strict:
- headers:off
- json:off

stages:
- name: create a job and check for success
request:
url: "{tavern.env_vars.IRS_HOST}/irs/jobs"
json:
key:
globalAssetId: "{tavern.env_vars.GLOBAL_ASSET_ID_AS_BUILT}"
bpn: "{tavern.env_vars.BPN_AS_BUILT}"
collectAspects: true
auditContractNegotiation: false
depth: 2
aspects:
- SerialPart
direction: "downward"
method: POST
headers:
content-type: application/json
$ext:
function: local.testing.api-tests.tavern_helpers:create_api_key
response:
status_code: 201
headers:
content-type: application/json
save:
json:
job_id: id

- *verify_job_is_running_and_wait_up_to_15_minutes_for_COMPLETED

- name: verify job response with desired test steps
request:
url: "{tavern.env_vars.IRS_HOST}/irs/jobs/{job_id}"
params:
returnUncompletedJob: true
method: GET
headers:
content-type: application/json
$ext:
function: local.testing.api-tests.tavern_helpers:create_api_key
response:
status_code: 200
verify_response_with:
- function: local.testing.api-tests.tavern_helpers:contractAgreementId_in_shells_not_existing
- function: local.testing.api-tests.tavern_helpers:contractAgreementId_in_submodels_not_existing
headers:
content-type: application/json
35 changes: 33 additions & 2 deletions local/testing/api-tests/tavern_helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# testing_utils.py
from datetime import datetime

import os
Expand Down Expand Up @@ -354,4 +353,36 @@ def create_api_key():
def create_api_key_ess():
api_key = os.getenv('ADMIN_USER_API_KEY_ESS')

return {"X-API-KEY": api_key}
return {"X-API-KEY": api_key}


def contractAgreementId_in_shells_existing(response):
shells = response.json().get("shells")
print("shells ", shells)
assert len(shells) >= 1
for i in shells:
assert i.get("contractAgreementId") is not None


def contractAgreementId_in_submodels_existing(response):
submodels = response.json().get("submodels")
print("submodels ", submodels)
assert len(submodels) >= 1
for i in submodels:
assert i.get("contractAgreementId") is not None


def contractAgreementId_in_shells_not_existing(response):
shells = response.json().get("shells")
print("shells ", shells)
assert len(shells) >= 1
for i in shells:
assert i.get("contractAgreementId") is None


def contractAgreementId_in_submodels_not_existing(response):
submodels = response.json().get("submodels")
print("submodels ", submodels)
assert len(submodels) >= 1
for i in submodels:
assert i.get("contractAgreementId") is None