Skip to content

Commit

Permalink
Merge pull request #760 from catenax-ng/feature/#370-add-tavern-tests…
Browse files Browse the repository at this point in the history
…-for-auditContractNegotiation

feat(testing):#370 added tavern tests for auditContractNegotiation
  • Loading branch information
ds-alexander-bulgakov authored Feb 6, 2024
2 parents d7bfe06 + c1116db commit 83d31d2
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 2 deletions.
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

0 comments on commit 83d31d2

Please sign in to comment.