Skip to content

Commit

Permalink
Do not treat recursive relationships as errors
Browse files Browse the repository at this point in the history
  • Loading branch information
otto-ifak committed May 30, 2024
1 parent ca0b1d3 commit 4154059
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 2 deletions.
3 changes: 1 addition & 2 deletions aas_test_engines/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ def _scan_relationships(zipfile: zipfile.ZipFile, parent_rel: Relationship, dir:
result.append(AasTestResult(f'Relationship {sub_rel.target} is of type {sub_rel.type}', str(idx), Level.INFO))
parent_rel.sub_rels.append(sub_rel)
if target in visited_targets:
result.append(AasTestResult(
'Recursive relationship', str(idx), Level.ERROR))
result.append(AasTestResult(f'Already checked {target}', str(idx), Level.INFO))
continue
visited_targets.add(target)
if target not in zipfile.namelist():
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/aasx/valid/recursive/[Content_Types].xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
<Default Extension="xml" ContentType="text/xml" />
<Default Extension="jpeg" ContentType="image/jpeg" />
<Default Extension="png" ContentType="image/png" />
<Default Extension="pdf" ContentType="application/pdf" />
<Default Extension="jpg" ContentType="image/jpeg" />
<Default Extension="zip" ContentType="text/plain" />
<Override PartName="/aasx/aasx-origin" ContentType="text/plain" />
</Types>
4 changes: 4 additions & 0 deletions test/fixtures/aasx/valid/recursive/_rels/.rels
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Type="http://admin-shell.io/aasx/relationships/aasx-origin" Target="/aasx/aasx-origin"/>
</Relationships>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Type="http://admin-shell.io/aasx/relationships/aas-spec" Target="/aasx/the_aas.json" />
<Relationship Type="http://admin-shell.io/aasx/relationships/aas-spec" Target="/aasx/aasx-origin" />
</Relationships>
Empty file.
96 changes: 96 additions & 0 deletions test/fixtures/aasx/valid/recursive/aasx/the_aas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"submodels": [
{
"id": "something_48c66017",
"modelType": "Submodel",
"submodelElements": [
{
"category": "VARIABLE",
"description": [
{
"language": "en",
"text": "something_be9deae0"
}
],
"displayName": [
{
"language": "Tvwqa-500-8EQd-y-8f5-k-vqdMn7-Ohw9-CcA628-DHKP-hPAjUZ-cnr1REUf-S8-p-9X0r-wtCI-KunG3uzI-7dGUsrTu-fY7-C3-hFN-Y-ML69DgnJ-0-Y0H-TLACBVB-Z0HRibbz-yzSf8dvR-zAn-B-6h8VjcKX-jnwR-0Z8l-ghRIZ7mo-wZG7-zXHdSIV-Oy-8dH00A6L-nJY2dA1-57o8dQ-RpxkBTbE-qBJR-M-DyGDA3U-aguRfIhj-x-XmO-1u",
"text": "something_535aeb51"
}
],
"embeddedDataSpecifications": [
{
"dataSpecification": {
"keys": [
{
"type": "Submodel",
"value": "urn:another-company15:2bd0986b"
}
],
"type": "ModelReference"
},
"dataSpecificationContent": {
"modelType": "DataSpecificationIec61360",
"preferredName": [
{
"language": "X-33DQI-g",
"text": "something_7e795ee2"
},
{
"language": "en-UK",
"text": "Something random in English c8512bdf"
}
],
"value": "something_4e9c19b7"
}
}
],
"extensions": [
{
"name": "something_aa1af8b3"
}
],
"idShort": "PiXO1wyHierj",
"modelType": "Property",
"qualifiers": [
{
"type": "something_500f973e",
"valueType": "xs:long"
}
],
"semanticId": {
"keys": [
{
"type": "GlobalReference",
"value": "urn:something00:f4547d0c"
}
],
"type": "ExternalReference"
},
"supplementalSemanticIds": [
{
"keys": [
{
"type": "Submodel",
"value": "urn:another-example10:42487f5a"
}
],
"type": "ModelReference"
}
],
"value": "0061707",
"valueId": {
"keys": [
{
"type": "Submodel",
"value": "urn:some-company12:e40857e0"
}
],
"type": "ModelReference"
},
"valueType": "xs:decimal"
}
]
}
]
}
6 changes: 6 additions & 0 deletions test/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ def test_relative_paths(self):
result.dump()
self.assertEqual(result.level, Level.INFO)

def test_recursive(self):
z = in_memory_zipfile(os.path.join(script_dir, 'fixtures/aasx/valid/recursive'))
result = file.check_aasx_data(z)
result.dump()
self.assertEqual(result.level, Level.WARNING)


class SupportedVersionTest(TestCase):

Expand Down

0 comments on commit 4154059

Please sign in to comment.