Skip to content

Commit

Permalink
Merge pull request #653 from catenax-ng/fix/#503-Fix-tests-Tavern-Cuc…
Browse files Browse the repository at this point in the history
…umber-Tests

fix(tavern):[#503] removing/comment out not needed tests
  • Loading branch information
ds-jhartmann authored May 22, 2024
2 parents 7e05834 + 591a0dd commit 55783ac
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 175 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tavern.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ on:
global-asset-id-asBuilt:
type: string
description: Global-asset-id to use for the asBuilt tests.
default: 'urn:uuid:8724338c-5c85-4c34-91eb-e2735d58fb0d'
default: 'urn:uuid:4509ea7c-c8d2-41a1-83ca-c214ee34af6c'
required: true
bpn-asBuilt:
type: string
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
BPN_ESS_AS_BUILT: ${{ github.event.inputs.bpn-ess-asBuilt || 'BPNL00000003CRHK' }}
BPN_ESS_INCIDENT: ${{ github.event.inputs.bpn-ess-incident || 'BPNS00000003B6LU' }}
BPN_AS_PLANNED: ${{ github.event.inputs.bpn-asPlanned || 'BPNL00000003AYRE' }}
GLOBAL_ASSET_ID_AS_BUILT: ${{ github.event.inputs.global-asset-id-asBuilt || 'urn:uuid:6d505432-8b31-4966-9514-4b753372683f' }}
GLOBAL_ASSET_ID_AS_BUILT: ${{ github.event.inputs.global-asset-id-asBuilt || 'urn:uuid:4509ea7c-c8d2-41a1-83ca-c214ee34af6c' }}
BPN_AS_BUILT: ${{ github.event.inputs.bpn-asBuilt || 'BPNL00000003AVTH' }}
run: |
python -m pytest local/testing/api-tests/irs-api-tests.tavern.yaml --junitxml=tavern-results.xml
Expand Down
232 changes: 62 additions & 170 deletions local/testing/api-tests/irs-api-tests.tavern.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,6 @@ stages:
status_code: 200
verify_response_with:
- function: local.testing.api-tests.tavern_helpers:submodels_are_empty
- function: local.testing.api-tests.tavern_helpers:submodelDescriptors_in_shells_are_empty
- function: local.testing.api-tests.tavern_helpers:aspects_in_job_parameter_are_empty
- function: local.testing.api-tests.tavern_helpers:relationships_are_not_empty
- function: local.testing.api-tests.tavern_helpers:check_timestamps_for_completed_jobs
Expand Down Expand Up @@ -1617,62 +1616,62 @@ stages:

---


test_name: Make sure job with aspects SerialPart and CertificateOfDestruction is processed (1.3.4)

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: "urn:uuid:4509ea7c-c8d2-41a1-83ca-c214ee34af6c"
bpn: "{tavern.env_vars.BPN_AS_BUILT}"
aspects:
- urn:samm:io.catenax.serial_part:3.0.0#SerialPart
- urn:samm:io.catenax.serial_part:2.0.0#CertificateOfDestruction
collectAspects: true
depth: 2
method: POST
headers:
content-type: application/json
$ext:
function: local.testing.api-tests.tavern_helpers:create_api_key
response:
status_code: 201
json:
id: !re_fullmatch "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
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 and check details
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:tombstones_are_empty
- function: local.testing.api-tests.tavern_helpers:relationships_are_not_empty
- function: local.testing.api-tests.tavern_helpers:submodels_are_not_empty
- function: local.testing.api-tests.tavern_helpers:check_timestamps_for_completed_jobs
headers:
content-type: application/json
# test not needed CertificateOfDestruction not included in testdata
#test_name: Make sure job with aspects SerialPart and CertificateOfDestruction is processed (1.3.4)
#
#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}"
# aspects:
# - urn:samm:io.catenax.serial_part:3.0.0#SerialPart
# - urn:samm:io.catenax.serial_part:2.0.0#CertificateOfDestruction
# collectAspects: true
# depth: 2
# method: POST
# headers:
# content-type: application/json
# $ext:
# function: local.testing.api-tests.tavern_helpers:create_api_key
# response:
# status_code: 201
# json:
# id: !re_fullmatch "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
# 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 and check details
# 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:tombstones_are_empty
# - function: local.testing.api-tests.tavern_helpers:relationships_are_not_empty
# - function: local.testing.api-tests.tavern_helpers:submodels_are_not_empty
# - function: local.testing.api-tests.tavern_helpers:check_timestamps_for_completed_jobs
# headers:
# content-type: application/json


---
Expand Down Expand Up @@ -2508,61 +2507,8 @@ stages:

---

# lookupBPNs are deprecated and no longer used
# test_name: Make sure IRS-jobs are running without BPN-lookups by default

# 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: false
# depth: 1
# 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:bpns_are_empty
# headers:
# content-type: application/json


---

# lookupBPNs are deprecated and no longer used
#test_name: Make sure IRS-jobs are running with BPN-lookups correctly
#lookupBPNs are deprecated and no longer used
#test_name: Make sure IRS-jobs with BPN-lookups content summary information
#
#strict:
# - headers:off
Expand All @@ -2577,8 +2523,7 @@ stages:
# globalAssetId: "{tavern.env_vars.GLOBAL_ASSET_ID_AS_BUILT}"
# bpn: "{tavern.env_vars.BPN_AS_BUILT}"
# collectAspects: false
# lookupBPNs: false
# depth: 1
# depth: 1
# direction: "downward"
# method: POST
# headers:
Expand All @@ -2589,9 +2534,9 @@ stages:
# status_code: 201
# headers:
# content-type: application/json
# save:
# save:
# json:
# job_id: id
# job_id: id
#
# - *verify_job_is_running_and_wait_up_to_15_minutes_for_COMPLETED
#
Expand All @@ -2609,64 +2554,11 @@ stages:
# status_code: 200
# verify_response_with:
# - function: local.testing.api-tests.tavern_helpers:bpns_are_not_empty
# - function: local.testing.api-tests.tavern_helpers:summary_for_bpns_is_given
# headers:
# content-type: application/json


---


test_name: Make sure IRS-jobs with BPN-lookups content summary information

strict:
- headers:off
- json:off

stages:
- name: create a job and wait
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: false
depth: 1
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:bpns_are_not_empty
- function: local.testing.api-tests.tavern_helpers:summary_for_bpns_is_given
headers:
content-type: application/json


---

############################## \/ Batch-Order tests for both irs/orders and irs/ess/orders \/ ##############################
Expand Down
8 changes: 5 additions & 3 deletions local/testing/api-tests/tavern_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime

import os
import re
from box import Box


Expand Down Expand Up @@ -49,8 +50,8 @@ def ESS_job_parameter_are_as_requested(response):
assert parameter.get('depth') == 1
assert parameter.get('direction') == 'downward'
aspects_list = parameter.get("aspects")
assert 'PartSiteInformationAsPlanned' in aspects_list
assert 'PartAsPlanned' in aspects_list
assert 'urn:samm:io.catenax.part_site_information_as_planned:1.0.0#PartSiteInformationAsPlanned' in aspects_list
assert 'urn:samm:io.catenax.part_as_planned:1.0.1#PartAsPlanned' in aspects_list


def tombstone_for_EssValidation_are_correct(response, expectedTombstone):
Expand Down Expand Up @@ -187,7 +188,8 @@ def status_of_all_jobs_are_given(response):
def errors_for_unknown_requested_globalAssetId_are_correct(response):
print(response.json().get("messages"))
error_list = response.json().get("messages")
assert 'No job exists with id bc1b4f4f-aa00-4296-8738-e7913c95f2d9' in error_list
pattern = r"No job exists with id bc1b4f4f-aa00-4296-8738-e7913c95f2d9 \(errorRef: [0-9a-fA-F-]{36}\)"
assert any(re.compile(pattern).search(element) for element in error_list), ( "No element in the list matches the expected error message pattern")


def check_timestamps_for_completed_jobs(response):
Expand Down

0 comments on commit 55783ac

Please sign in to comment.