basyx-python-sdk icon indicating copy to clipboard operation
basyx-python-sdk copied to clipboard

compliance_tool: Replace fixture files with mocking

Open hpoeche opened this issue 5 months ago • 0 comments

The compliance tool tests previously relied on handcrafted example fixture files (JSON, XML, AASX) to drive end-to-end assertions. These fixtures duplicated the SDK's own example data and had to be manually maintained on updates of the metamodel.

Changes

JSON/XML (test_compliance_check_json.py, test_compliance_check_xml.py)

The fixture files under compliance_tool/test/files/ have been removed. In their place, the tests now mock the underlying SDK adapter function (read_aas_json_file, read_aas_xml_file, AASXReader) as well as the AASDataChecker. Those parts of the implementation are already tested in the unittests of the SDK, leaving only wrapping and output parsing to be tested here.

The _test_helper.py file collects utility functions used to create the mocks of the adapter functions.

AASX (test_compliance_check_aasx.py)

For the AASX compliance checks only the deserialization and the comparison of the AAS Objects are done through SDK functionalities. Checks on the core-properties and the supplementary files are implemented in the compliance_tool directly. Therefore new test cases were introduced for

  1. Core-property mismatch detection
  2. Supplementary file presence and content equality (via checksum)

Compliance Tool (test_aas_compliance_tool.py)

The old e2e tests were also relying on fixture files and are therefore replaced with tests which ensure

  1. correct parsing of CLI arguments
  2. routing of CLI calls to the correct function of the correct compliance_check_* file
  3. logging files containing the whole output

Discovered Bugs

The new test cases for the test_compliance_check_aasx.py revealed the following three bugs:

  • [ ] check_aas_example: Check of the supplementary files sha256 is checking nothing, as the code simplifies to files.get_sha256('/TestFile.pdf') == files.get_sha256('/TestFile.pdf').
  • [ ] check_aasx_files_equivalence: If one file fails to open, the core-property check is still tried to execute but raises an assertion instead of proper output.
  • [ ] check_aasx_files_equivalence: Missing or unequal supplementary files do not lead to a FAILED status.

As discussed these minor issues will be fixed in this pull request.

Fix #486

hpoeche avatar Jun 16 '26 12:06 hpoeche