Repository: AlgebraicJulia/py-acsets (language: python)

Issue:
Add Schemas for Stock and Flow
Not entirely sure what some of the tables are, need to update once I talk to @Xiaoyan-Li.


Discussion / hints:

Fix patch:
diff --git a/setup.cfg b/setup.cfg
index 552b740..8ba557d 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -68,6 +68,7 @@ where = src
 tests =
     pytest
     coverage
+    jsonschema
 docs =
     sphinx
     sphinx-rtd-theme
diff --git a/src/acsets/schemas/__init__.py b/src/acsets/schemas/__init__.py
new file mode 100644
index 0000000..7229e07
--- /dev/null
+++ b/src/acsets/schemas/__init__.py
@@ -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")
diff --git a/src/acsets/schemas/examples/README.md b/src/acsets/schemas/examples/README.md
new file mode 100644
index 0000000..7aa2ddc
--- /dev/null
+++ b/src/acsets/schemas/examples/README.md
@@ -0,0 +1,3 @@
+# Examples
+
+This repository contains examples corresponding to the JSON schemata.


Test patch:
diff --git a/tests/test_examples.py b/tests/test_examples.py
new file mode 100644
index 0000000..deb6f9b
--- /dev/null
+++ b/tests/test_examples.py
@@ -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)