Skip to content

Commit

Permalink
tests: python: Validate output using JSON schema
Browse files Browse the repository at this point in the history
The output from the python bindings should conform to the corresponding
JSON schema, so test this
  • Loading branch information
JPEWdev committed Feb 23, 2024
1 parent 0941592 commit 8549e70
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# SPDX-License-Identifier: MIT

import json
import jsonschema
import pytest
import re
import subprocess
Expand Down Expand Up @@ -199,6 +200,16 @@ def test_roundtrip(spdx3_import, tmp_path):
assert outdata == indata


def test_jsonschema_validation():
with (THIS_DIR / "expect" / "jsonschema" / "spdx3-context.json").open("r") as f:
schema = json.load(f)

with (DATA_DIR / "python" / "roundtrip.json").open("r") as f:
data = json.load(f)

jsonschema.validate(data, schema=schema)


def test_links(spdx3_import):
import spdx3

Expand Down

0 comments on commit 8549e70

Please sign in to comment.