Skip to content

Commit

Permalink
Minor improvements (fixes #66)
Browse files Browse the repository at this point in the history
  • Loading branch information
otto-ifak committed Nov 21, 2024
1 parent 9e9f36a commit f192945
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
30 changes: 22 additions & 8 deletions aas_test_engines/test_cases/v3_0/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import requests

import base64
import json

from .model import AssetAdministrationShell, Environment
from .parse import parse_and_check_json
Expand Down Expand Up @@ -597,7 +598,7 @@ def setup(self):
self.valid_id_short: str = _lookup(data, ['result', 0, 'idShort'])
global_asset_id = _lookup(data, ['result', 0, 'assetInformation', 'globalAssetId'], None)
if global_asset_id:
self.asset_id = {'name': 'globalAssetId', 'value': 'globalAssetId'}
self.asset_id = {'name': 'globalAssetId', 'value': global_asset_id}
else:
self.asset_id = _lookup(data, ['result', 0, 'specificAssetIds', 0])
self.cursor = _lookup(data, ['paging_metadata', 'cursor'], None)
Expand Down Expand Up @@ -642,8 +643,10 @@ def test_filter_by_asset_id(self):
"""
Filter by assetId
"""
request = generate_one_valid(self.operation, self.sample_cache, {'assetIds': self.asset_id})
_invoke_and_decode(request, self.conf, True)
encoded_asset_id = base64.b64encode(json.dumps(self.asset_id).encode()).decode()
request = generate_one_valid(self.operation, self.sample_cache, {'assetIds': encoded_asset_id})
data = _invoke_and_decode(request, self.conf, True)
_assert(len(data["result"]) != 0, "Returns non-empty list")


@operation("GetAllAssetAdministrationShells")
Expand All @@ -667,7 +670,12 @@ def test_filter_by_idshort(self):
request = generate_one_valid(self.operation, self.sample_cache, {'idShort': self.valid_id_short})
_invoke_and_decode(request, self.conf, True)

#####################################
# AssetAdministrationShell Interface
#####################################

# /shells/<AAS>
# /aas


@operation("GetAssetAdministrationShellById")
Expand Down Expand Up @@ -727,6 +735,9 @@ def test_simple(self):
request = generate_one_valid(self.operation, self.sample_cache, {'aasIdentifier': b64urlsafe(self.valid_id)})
_invoke_and_decode(request, self.conf, True)

# TODO: fetch by semantic id
# TODO: fetch by idShort
# TODO: two pagination tests

# /shells/<AAS>/submodel-refs

Expand Down Expand Up @@ -760,6 +771,7 @@ def test_pagination(self):
data = _lookup(data, ['result'])
_assert(len(data) == 1, 'Exactly one entry')

# TODO: set limit=1 and fetch only one

# /shells/<AAS>/asset-information

Expand Down Expand Up @@ -921,7 +933,7 @@ class GetSubmodel_Reference(SubmodelSuite, GetSubmodelRefsTests):
# /shells/<AAS>/submodels/<SM>/submodel-elements


class GetSubmodelElementTests(ApiTestSuite):
class GetSubmodelElementsTests(ApiTestSuite):
def test_simple(self):
"""
Fetch all submodel elements
Expand Down Expand Up @@ -969,19 +981,20 @@ def test_extent_without_blob_value(self):
})
_invoke_and_decode(request, self.conf, True)

# TODO: two pagination tests are missing

@operation("GetAllSubmodelElements_AasRepository")
class GetAllSubmodelElements_AasRepository(SubmodelByAasRepoSuite, GetSubmodelElementTests):
class GetAllSubmodelElements_AasRepository(SubmodelByAasRepoSuite, GetSubmodelElementsTests):
pass


@operation("GetAllSubmodelElements_SubmodelRepository")
class GetAllSubmodelElements_SubmodelRepository(SubmodelBySubmodelRepoSuite, GetSubmodelElementTests):
class GetAllSubmodelElements_SubmodelRepository(SubmodelBySubmodelRepoSuite, GetSubmodelElementsTests):
pass


@operation("GetAllSubmodelElements")
class GetAllSubmodelElements(SubmodelSuite, GetSubmodelElementTests):
class GetAllSubmodelElements(SubmodelSuite, GetSubmodelElementsTests):
pass


Expand Down Expand Up @@ -1146,7 +1159,7 @@ def setup(self):
self.valid_values['idShortPath'] = _first_iterator_item(self.paths.values())[0]


class SubmodelElementBySuperpathSuite(SubmodelElementTestsBase):
class GetSubmodelElementTests(SubmodelElementTestsBase):
supported_submodel_elements = {
'SubmodelElementCollection',
'SubmodelElementList',
Expand Down Expand Up @@ -1501,6 +1514,7 @@ def test_include_concept_descriptions(self):
if data:
_assert('conceptDescriptions' in data, 'contains conceptDescriptions', Level.WARNING)

# TODO: invoke without params

# /description

Expand Down
2 changes: 1 addition & 1 deletion aas_test_engines/test_cases/v3_0/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, raw_value: str):

if self.pattern:
if re.fullmatch(self.pattern, raw_value) is None:
raise ValueError("String does not match pattern")
raise ValueError(f"String '{raw_value}' does not match pattern")

def __eq__(self, other: "StringFormattedValue") -> bool:
return self.raw_value == other.raw_value
Expand Down

0 comments on commit f192945

Please sign in to comment.