From 0628968de0aa3887f1b130a2cc8b565435b59041 Mon Sep 17 00:00:00 2001 From: "Keto D. Zhang" Date: Sat, 16 Nov 2024 21:44:18 -0800 Subject: [PATCH] feat!: migrate example models to tests/ and remove example extension from package --- asdf_pydantic/examples/__init__.py | 0 asdf_pydantic/examples/extensions.py | 19 ------------------- pyproject.toml | 3 --- tests/convert_to_asdf_yaml_tree_test.py | 2 +- tests/entry_point_test.py | 11 ----------- {asdf_pydantic => tests}/examples/shapes.py | 0 tests/examples/test_rectangle.py | 9 ++------- {asdf_pydantic => tests}/examples/tree.py | 0 tests/schema_validation_test.py | 4 ++-- 9 files changed, 5 insertions(+), 43 deletions(-) delete mode 100644 asdf_pydantic/examples/__init__.py delete mode 100644 asdf_pydantic/examples/extensions.py delete mode 100644 tests/entry_point_test.py rename {asdf_pydantic => tests}/examples/shapes.py (100%) rename {asdf_pydantic => tests}/examples/tree.py (100%) diff --git a/asdf_pydantic/examples/__init__.py b/asdf_pydantic/examples/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/asdf_pydantic/examples/extensions.py b/asdf_pydantic/examples/extensions.py deleted file mode 100644 index b79d4d9..0000000 --- a/asdf_pydantic/examples/extensions.py +++ /dev/null @@ -1,19 +0,0 @@ -from __future__ import annotations - -from asdf.extension import Extension - -from asdf_pydantic.converter import AsdfPydanticConverter -from asdf_pydantic.examples.shapes import AsdfRectangle -from asdf_pydantic.examples.tree import AsdfTreeNode - -AsdfPydanticConverter.add_models(AsdfRectangle, AsdfTreeNode) - - -class ExampleExtension(Extension): - extension_uri = "asdf://asdf-pydantic/examples/extensions/examples-1.0.0" - converters = [AsdfPydanticConverter()] # type: ignore - tags = [*AsdfPydanticConverter().tags] # type: ignore - - -def get_extensions() -> list[Extension]: - return [ExampleExtension()] diff --git a/pyproject.toml b/pyproject.toml index ed3c434..d71650b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,9 +34,6 @@ Documentation = "https://asdf-pydantic.readthedocs.io" Issues = "https://github.com/ketozhang/asdf-pydantic/issues" Source = "https://github.com/ketozhang/asdf-pydantic" -[project.entry-points] -'asdf.extensions' = { asdf_pydantic_extension = 'asdf_pydantic.examples.extensions:get_extensions' } - [tool.hatch.version] source = "vcs" diff --git a/tests/convert_to_asdf_yaml_tree_test.py b/tests/convert_to_asdf_yaml_tree_test.py index 37825e1..2f9510f 100644 --- a/tests/convert_to_asdf_yaml_tree_test.py +++ b/tests/convert_to_asdf_yaml_tree_test.py @@ -1,6 +1,6 @@ from __future__ import annotations -from asdf_pydantic.examples.tree import AsdfTreeNode, Node +from tests.examples.tree import AsdfTreeNode, Node def test_sanity(): diff --git a/tests/entry_point_test.py b/tests/entry_point_test.py deleted file mode 100644 index efccb39..0000000 --- a/tests/entry_point_test.py +++ /dev/null @@ -1,11 +0,0 @@ -from tempfile import NamedTemporaryFile - -import asdf - -from asdf_pydantic.examples.shapes import AsdfRectangle - - -def test_create_asdf_file(): - with NamedTemporaryFile() as tempfile: - af = asdf.AsdfFile({"rect": AsdfRectangle(width=42, height=10)}) - af.write_to(tempfile.name) diff --git a/asdf_pydantic/examples/shapes.py b/tests/examples/shapes.py similarity index 100% rename from asdf_pydantic/examples/shapes.py rename to tests/examples/shapes.py diff --git a/tests/examples/test_rectangle.py b/tests/examples/test_rectangle.py index a95a2ba..9d414d7 100644 --- a/tests/examples/test_rectangle.py +++ b/tests/examples/test_rectangle.py @@ -7,13 +7,8 @@ import yaml from asdf.extension import Extension -from asdf_pydantic import AsdfPydanticConverter, AsdfPydanticModel - - -class AsdfRectangle(AsdfPydanticModel): - _tag = "asdf://asdf-pydantic/examples/tags/rectangle-1.0.0" - width: float - height: float +from asdf_pydantic import AsdfPydanticConverter +from tests.examples.shapes import AsdfRectangle @pytest.fixture() diff --git a/asdf_pydantic/examples/tree.py b/tests/examples/tree.py similarity index 100% rename from asdf_pydantic/examples/tree.py rename to tests/examples/tree.py diff --git a/tests/schema_validation_test.py b/tests/schema_validation_test.py index a5365b5..73b4d52 100644 --- a/tests/schema_validation_test.py +++ b/tests/schema_validation_test.py @@ -7,8 +7,8 @@ from asdf.extension import Extension from asdf_pydantic import AsdfPydanticConverter -from asdf_pydantic.examples.shapes import AsdfRectangle -from asdf_pydantic.examples.tree import AsdfTreeNode +from tests.examples.shapes import AsdfRectangle +from tests.examples.tree import AsdfTreeNode def setup_module():