-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ where = src | |
tests = | ||
pytest | ||
coverage | ||
jsonschema | ||
docs = | ||
sphinx | ||
sphinx-rtd-theme | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"""Schemas and examples.""" | ||
|
||
from pathlib import Path | ||
|
||
HERE = Path(__file__).parent.resolve() | ||
CATLAB = HERE.joinpath("catlab") | ||
JSONSCHEMA = HERE.joinpath("jsonschema") | ||
EXAMPLES = HERE.joinpath("examples") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Examples | ||
|
||
This repository contains examples corresponding to the JSON schemata. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Test that the examples are valid.""" | ||
|
||
import json | ||
import unittest | ||
|
||
import jsonschema | ||
from acsets.schemas import EXAMPLES, CATLAB, JSONSCHEMA | ||
|
||
|
||
class TestExamples(unittest.TestCase): | ||
"""Test all examples are valid wrt their related schema.""" | ||
|
||
def test_examples_valid(self): | ||
"""Test examples.""" | ||
for example in EXAMPLES.glob("*.json"): | ||
with self.subTest(example=example.name): | ||
jsonschema_path = JSONSCHEMA.joinpath(example.name) | ||
self.assertTrue( | ||
jsonschema_path.is_file(), msg="No corresponding JSON schema for example" | ||
) | ||
jsonschema_obj = json.loads(jsonschema_path.read_text()) | ||
example_obj = json.loads(example.read_text()) | ||
jsonschema.validate(instance=example_obj, schema=jsonschema_obj) |