-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for defining tags with asdf.extension.TagDefinition (#27)
- Loading branch information
Showing
5 changed files
with
80 additions
and
18 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
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
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
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
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,51 @@ | ||
import pytest | ||
from asdf.extension import TagDefinition | ||
|
||
from asdf_pydantic import AsdfPydanticModel | ||
|
||
|
||
def tag(request): | ||
return request.param | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"tag", | ||
( | ||
"asdf://asdf-pydantic/test/tags/", | ||
pytest.param( | ||
TagDefinition("asdf://asdf-pydantic/tags/test-0.0.1"), | ||
marks=pytest.mark.xfail( | ||
reason="Tag definition without schema URIs not supported" | ||
), | ||
), | ||
TagDefinition( | ||
"asdf://asdf-pydantic/tags/test-0.0.1", | ||
schema_uris=["asdf://asdf-pydantic/test/schemas/test-0.0.1"], | ||
), | ||
), | ||
) | ||
def test_can_get_tag_definition(tag): | ||
class TestModel(AsdfPydanticModel): | ||
_tag = tag | ||
|
||
tag_definition = TestModel.get_tag_definition() | ||
assert isinstance(tag_definition, TagDefinition) | ||
assert tag_definition.schema_uris | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"tag", | ||
( | ||
"asdf://asdf-pydantic/test/tags/", | ||
TagDefinition("asdf://asdf-pydantic/tags/test-0.0.1"), | ||
TagDefinition( | ||
"asdf://asdf-pydantic/tags/test-0.0.1", | ||
schema_uris=["asdf://asdf-pydantic/test/schemas/test-0.0.1"], | ||
), | ||
), | ||
) | ||
def test_can_get_tag_uris(tag): | ||
class TestModel(AsdfPydanticModel): | ||
_tag = tag | ||
|
||
assert TestModel.get_tag_uri() |