Proposal: consolidate JSON schema tests using keys#116
Proposal: consolidate JSON schema tests using keys#116
Conversation
Rather than splitting files into individual folders, this commit makes use of top-level keys (valid, recommended) to indicate whether a file should validate against image.schema and strict_image.schema The unit tests are updated to use a single glob and detect the appropriate schema based on the presence of the multiscales key
|
Looks good 👍 |
will-moore
left a comment
There was a problem hiding this comment.
Looks good. Slightly counter-intuitive to add false flags, but I think I can understand.
Do you mean the keys should be expected to have different default values? Or that the new keys should be defined in all snippets whether they are |
|
My reading of https://github.com/json-schema-org/JSON-Schema-Test-Suite#structure-of-a-test made me expect rather than: to have: |
|
True, the JSON schema test suite format wraps the JSON to test within a I hesitated to implement it as part of the proposal primarily because it breaks the inclusion logic of #98. If the format sounds valuable, I can look into refactoring these examples one step further to follow the JSON schema test suite format more closely. |
Ah, understood. But we'll need to strip |
Maybe that's the bit of explanation that was missing in my answer to @will-moore's question above. To avoid stripping of the |
|
Summary of a quick discussion with @joshmoore. Having spent more time implementing #116 (comment), I am increasingly considering the following organisation which should bring a good compromise between extensibility and support for new specification schemas and usability:
|
See #112 (comment) for more context. As new JSON schemas and associated validation samples are about to be introduced both for existing and upcoming specification, the initial layout for the JSON test files need to be revisited.
This PR explores an alternative proposal to the top-level
valid,valid_strict,invalidfolders introduced in #87 #92 and is inspired by the JSON schema test suite - https://github.com/json-schema-org/JSON-Schema-Test-Suite#structure-of-a-test.Each JSON file can annoted with a top-level
validand/orrecommendedkey which indicates whether the metadata is minimally compliant or fully compliant with the specification. The Python tests are updated to use a singleglob.globand collect all*.jsonfiles, select the schema to use based on the presence of themultiscaleskey and use thevalid/recommendedkeys to test thevalidateoutcome.Using this approach, all JSON files associated with the
image.schemacan be simply grouped into theexamples/imagesubfolder, examples associated withplate.schemawould be underexamples/plateetc