opensupplyhub / supplychaindata.exchange

supplychaindata.exchange.schema
Creative Commons Zero v1.0 Universal
4 stars 2 forks source link

Add tests mechanisms to schema structure #14

Closed scrthq closed 2 weeks ago

scrthq commented 2 weeks ago

This PR includes the following proposed changes:

  1. Restructures the examples directory structure to enable easy testing without duplication of test data. This includes examples of invalid JSON documents that do not meet the schema.
    • Any partial example (e.g. location, affiliation, organization) has been moved into the partials subdirectory for clarity that it is not a working full example, but a partial one.
    • Full examples have been moved to a new full subdirectory with valid and invalid subdirectories underneath.
  2. Adjusts the upstream JSON schema metaschema to use Draft7 for better integration support, as we are not using any advanced JSON schema features that necessitate a different metaschema version than one that is standard.
  3. Adds the tests directory with a Python-based test suite that...
    1. Checks if the schema itself is valid against the Draft07 validator from the jsonschema package.
    2. Checks that all examples under examples/full/valid are valid against the schema.
    3. Checks that all examples under examples/full/invalid throw ValidationError's against the schema.
  4. Adds a GitHub Actions workflow that will run the test suite on any branch push or pull request opening
  5. Attaches test results to the PR and Workflow summary.
  6. Creates a central location-identifier definition, references that definition at the field level to deduplicate field definitions.

Example PR workflow run:

https://github.com/scrthq/supplychaindata.exchange/actions/runs/11644851819

Comment on PR with results:

2024-11-02 at 13 19 23

shuyag commented 2 weeks ago

Awesome addition of test mechanisms and the partials folder -- will direct people to look at this folder either to complete extensions or try out new ones. Thanks so much @scrthq!