Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delegate conformance checking to schema validation #117

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pywcmp provides validation and quality assessment capabilities for the [WMO
WIS](https://community.wmo.int/activity-areas/wis/wis-overview) Core Metadata
Profile (WCMP).

- validation against [WCMP 2 (draft)](https://github.com/wmo-im/wcmp2), specifically [Annex A: Conformance Class Abstract Test Suite](https://wmo-im.github.io/wcmp2/standard/wcmp2-DRAFT.html#_conformance_class_abstract_test_suite_normative), implementing an executable test suite against the ATS
- validation against [WCMP2 (draft)](https://github.com/wmo-im/wcmp2), specifically [Annex A: Conformance Class Abstract Test Suite](https://wmo-im.github.io/wcmp2/standard/wcmp2-DRAFT.html#_conformance_class_abstract_test_suite_normative), implementing an executable test suite against the ATS
- quality assessement against the [WCMP Key Performance Indicators](https://community.wmo.int/activity-areas/wis/wis-metadata-kpis)

## Installation
Expand Down Expand Up @@ -47,13 +47,13 @@ pywcmp bundle sync

# abstract test suite

# validate WCMP 2 metadata against abstract test suite (file on disk)
# validate WCMP2 metadata against abstract test suite (file on disk)
pywcmp ets validate /path/to/file.json

# validate WCMP 2 metadata against abstract test suite (URL)
# validate WCMP2 metadata against abstract test suite (URL)
pywcmp ets validate https://example.org/path/to/file.json

# validate WCMP 2 metadata against abstract test suite (URL), but turn JSON Schema validation off
# validate WCMP2 metadata against abstract test suite (URL), but turn JSON Schema validation off
pywcmp ets validate https://example.org/path/to/file.json --no-fail-on-schema-validation

# adjust debugging messages (CRITICAL, ERROR, WARNING, INFO, DEBUG) to stdout
Expand Down
2 changes: 1 addition & 1 deletion pywcmp/ets.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def validate(ctx, file_or_url, logfile, verbosity,
raise click.ClickException(err)
ctx.exit(1)

click.echo('Detected WCMP 2 discovery metadata')
click.echo('Detected WCMP2 discovery metadata')
ts = WMOCoreMetadataProfileTestSuite2(data)
try:
results = ts.run_tests(fail_on_schema_validation)
Expand Down
11 changes: 2 additions & 9 deletions pywcmp/wcmp2/ets.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,12 @@ def test_requirement_conformance(self):
Validate that a WCMP record provides valid conformance information.
"""

conformance_class = 'http://wis.wmo.int/spec/wcmp/2/conf/core'

status = {
'id': gen_test_id('conformance'),
'code': 'PASSED'
'code': 'PASSED',
'message': 'Passes given schema is compliant/valid'
}

conformance = self.record.get('conformsTo')

if conformance_class not in conformance:
status['code'] = 'FAILED'
status['message'] = f'Missing conformance class {conformance_class}' # noqa

return status

def test_requirement_type(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def test_fail(self):

codes = [r['code'] for r in results['ets-report']['tests']]

self.assertEqual(codes.count('FAILED'), 4)
self.assertEqual(codes.count('PASSED'), 8)
self.assertEqual(codes.count('FAILED'), 3)
self.assertEqual(codes.count('PASSED'), 9)
self.assertEqual(codes.count('SKIPPED'), 0)

with self.assertRaises(ValueError):
Expand Down
Loading