From cb4387c8111bf47e96957c07e875fed862899e92 Mon Sep 17 00:00:00 2001 From: "Keto D. Zhang" <keto.zhang@gmail.com> Date: Sun, 25 Aug 2024 21:25:56 -0700 Subject: [PATCH] test: add check schema test cases --- tests/examples/test_node.py | 7 +++++++ tests/examples/test_rectangle.py | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/tests/examples/test_node.py b/tests/examples/test_node.py index 6c248d0..09cdb6d 100644 --- a/tests/examples/test_node.py +++ b/tests/examples/test_node.py @@ -74,6 +74,13 @@ class TestExtension(Extension): yield asdf_config +@pytest.mark.usefixtures("asdf_extension") +def test_check_schema(): + """Tests the model schema is correct.""" + schema = yaml.safe_load(AsdfNode.model_asdf_schema()) + asdf.schema.check_schema(schema) + + @pytest.mark.usefixtures("asdf_extension") def test_can_write_valid_asdf_file(tmp_path): """Tests using the model to write an ASDF file validates its own schema.""" diff --git a/tests/examples/test_rectangle.py b/tests/examples/test_rectangle.py index 77adefc..a95a2ba 100644 --- a/tests/examples/test_rectangle.py +++ b/tests/examples/test_rectangle.py @@ -2,6 +2,7 @@ from unittest.mock import MagicMock, patch import asdf +import asdf.schema import pytest import yaml from asdf.extension import Extension @@ -38,6 +39,13 @@ class TestExtension(Extension): yield asdf_config +@pytest.mark.usefixtures("asdf_extension") +def test_check_schema(): + """Tests the model schema is correct.""" + schema = yaml.safe_load(AsdfRectangle.model_asdf_schema()) + asdf.schema.check_schema(schema) + + @pytest.mark.usefixtures("asdf_extension") def test_can_write_valid_asdf_file(tmp_path): """Tests using the model to write an ASDF file validates its own schema."""