Skip to content

Commit

Permalink
add js checks
Browse files Browse the repository at this point in the history
  • Loading branch information
schristley committed Apr 30, 2024
1 parent 199a829 commit 52a4c81
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/check-consistency-formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
v3spec_files = {basename(f): f for f in glob('specs/airr-schema-openapi3.yaml')}
py_files = {basename(f): f for f in glob('lang/python/airr/specs/airr-schema.yaml')}
r_files = {basename(f): f for f in glob('lang/R/inst/extdata/airr-schema.yaml')}
js_files = {basename(f): f for f in glob('lang/js/airr-schema-openapi3.yaml')}

# Check python package specs
if set(spec_files.keys()) != set(py_files.keys()):
Expand All @@ -35,6 +36,14 @@
print('{} found in R package but missing from specs/'.format(spec), file=sys.stderr)
sys.exit(1)

# Check JavaScript package specs
if set(v3spec_files.keys()) != set(js_files.keys()):
for spec in set(v3spec_files.keys()) - set(js_files.keys()):
print('{} missing from JavaScript package'.format(spec), file=sys.stderr)
for spec in set(js_files.keys()) - set(v3spec_files.keys()):
print('{} found in JavaScript package but missing from specs/'.format(spec), file=sys.stderr)
sys.exit(1)

for spec_name in spec_files:
# check equality of specs
with open(spec_files[spec_name], 'r') as ip:
Expand All @@ -56,6 +65,19 @@
print(jsondiff.diff(gold_spec, r_spec), file=sys.stderr)
sys.exit(1)

for spec_name in v3spec_files:
# check equality of specs
with open(v3spec_files[spec_name], 'r') as ip:
gold_spec = yaml.safe_load(ip)
with open(js_files[spec_name], 'r') as ip:
js_spec = yaml.safe_load(ip)

# Check JavaScript package
if jsondiff.diff(gold_spec, js_spec) != {}:
print('{} spec is different from python version'.format(spec_name), file=sys.stderr)
print(jsondiff.diff(gold_spec, js_spec, syntax='explicit'), file=sys.stderr)
sys.exit(1)

# Check OpenAPI3 spec vs OpenAPI2
for spec_name in spec_files:
with open(spec_files[spec_name], 'r') as ip:
Expand Down

0 comments on commit 52a4c81

Please sign in to comment.