Skip to content

Commit 9d01620

Browse files
authored
Remove binary files from test files for compliance tool (#143)
* Remove binary files from test files As binary files are not appropriate for git, we decided instead to create folders with the exact structure like in .aasx files and zip these folder when initializing a ComplianceToolAASXTest. * Add setUpClass() and tearDownClass(). Instead init() use setUpClass() to generate AASX files with zipped dirs and delete these AASX files after tests are finished. * Remove test_empty.aasx binary It will be generated in ComplianceToolAASXTest.setUpClass() * Remove ComplianceToolAASXTest.tearDownClass() As other tests also need AASX files, we cannot remove AASX files after all Tests in ComplianceToolAASXTest are run. That is why tearDownClass() was removed * Move generation of AASX files to __init__.py As other tests also need AASX files, we cannot generate AASX files in ComplianceToolAASXTest, because other tests can be run before or without tests from ComplianceToolAASXTest.
1 parent 8fbaa64 commit 9d01620

File tree

34 files changed

+9423
-0
lines changed

34 files changed

+9423
-0
lines changed

test/compliance_tool/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
import zipfile
3+
4+
AASX_FILES = ("test_demo_full_example_json_aasx",
5+
"test_demo_full_example_xml_aasx",
6+
"test_demo_full_example_xml_wrong_attribute_aasx",
7+
"test_empty_aasx")
8+
9+
10+
def _zip_directory(directory_path, zip_file_path):
11+
"""Zip a directory recursively."""
12+
with zipfile.ZipFile(zip_file_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
13+
for root, _, files in os.walk(directory_path):
14+
for file in files:
15+
file_path = os.path.join(root, file)
16+
arcname = os.path.relpath(file_path, directory_path)
17+
zipf.write(file_path, arcname=arcname)
18+
19+
20+
def generate_aasx_files():
21+
"""Zip dirs and create test AASX files."""
22+
script_dir = os.path.dirname(__file__)
23+
for i in AASX_FILES:
24+
_zip_directory(os.path.join(script_dir, "files", i),
25+
os.path.join(script_dir, "files", i.rstrip("_aasx") + ".aasx"))
26+
27+
28+
generate_aasx_files()
Binary file not shown.
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Override PartName="/aasx/aasx-origin" ContentType="text/plain"></Override><Override PartName="/aasx/data.json" ContentType="application/json"></Override><Override PartName="/TestFile.pdf" ContentType="application/pdf"></Override><Override PartName="/aasx/_rels/data.json.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"></Override><Override PartName="/docProps/core.xml" ContentType="application/xml"></Override><Override PartName="/aasx/_rels/aasx-origin.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"></Override><Override PartName="/_rels/.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"></Override></Types>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Target="/aasx/aasx-origin" Id="r1" Type="http://admin-shell.io/aasx/relationships/aasx-origin" TargetMode="Internal"></Relationship><Relationship Target="/docProps/core.xml" Id="r2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" TargetMode="Internal"></Relationship></Relationships>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Target="/aasx/data.json" Id="r0" Type="http://admin-shell.io/aasx/relationships/aas-spec" TargetMode="Internal"></Relationship></Relationships>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Target="/testfile.pdf" Id="r0" Type="http://admin-shell.io/aasx/relationships/aas-suppl" TargetMode="Internal"></Relationship></Relationships>

test/compliance_tool/files/test_demo_full_example_json_aasx/aasx/aasx-origin

Whitespace-only changes.

0 commit comments

Comments
 (0)