diff --git a/local/testing/api-tests/irs-api-tests.tavern.yaml b/local/testing/api-tests/irs-api-tests.tavern.yaml index c9de2ed681..e76a085bfd 100644 --- a/local/testing/api-tests/irs-api-tests.tavern.yaml +++ b/local/testing/api-tests/irs-api-tests.tavern.yaml @@ -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 \ No newline at end of file diff --git a/local/testing/api-tests/tavern_helpers.py b/local/testing/api-tests/tavern_helpers.py index 22f7c934d2..50a0a0164e 100644 --- a/local/testing/api-tests/tavern_helpers.py +++ b/local/testing/api-tests/tavern_helpers.py @@ -1,4 +1,3 @@ -# testing_utils.py from datetime import datetime import os @@ -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} \ No newline at end of file + 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