initial commit after automated creating
This commit is contained in:
commit
1cf124a5a3
48 changed files with 12041 additions and 0 deletions
72
tests/test_models.py
Normal file
72
tests/test_models.py
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
"""Basic smoke tests for Pydantic model validation."""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from agravity_client.models import (
|
||||
Asset,
|
||||
AssetBlob,
|
||||
AssetBlobType,
|
||||
AssetPageResult,
|
||||
Collection,
|
||||
AgravityVersion,
|
||||
SearchResult,
|
||||
AzSearchOptions,
|
||||
)
|
||||
|
||||
|
||||
class TestAssetModel:
|
||||
def test_minimal_asset(self):
|
||||
asset = Asset.model_validate({"id": "abc123"})
|
||||
assert asset.id == "abc123"
|
||||
|
||||
def test_asset_with_blob_type_enum(self):
|
||||
asset = Asset.model_validate({
|
||||
"id": "abc",
|
||||
"asset_type": "IMAGE",
|
||||
})
|
||||
assert asset.asset_type == "IMAGE"
|
||||
|
||||
def test_asset_page_result(self):
|
||||
result = AssetPageResult.model_validate({
|
||||
"assets": [{"id": "a1"}, {"id": "a2"}],
|
||||
"size": 2,
|
||||
})
|
||||
assert len(result.assets) == 2
|
||||
assert result.assets[0].id == "a1"
|
||||
|
||||
def test_extra_fields_allowed(self):
|
||||
"""Unknown API fields must not raise ValidationError."""
|
||||
asset = Asset.model_validate({"id": "x", "future_field": "value"})
|
||||
assert asset.id == "x"
|
||||
|
||||
|
||||
class TestCollectionModel:
|
||||
def test_minimal_collection(self):
|
||||
coll = Collection.model_validate({"id": "c1", "name": "Root"})
|
||||
assert coll.id == "c1"
|
||||
assert coll.name == "Root"
|
||||
|
||||
|
||||
class TestVersionModel:
|
||||
def test_agravity_version(self):
|
||||
v = AgravityVersion.model_validate({
|
||||
"name": "Agravity",
|
||||
"version": "10.3.0",
|
||||
})
|
||||
assert v.version == "10.3.0"
|
||||
|
||||
|
||||
class TestSearchModels:
|
||||
def test_search_options_defaults(self):
|
||||
opts = AzSearchOptions()
|
||||
assert opts.limit is None
|
||||
|
||||
def test_search_options_with_values(self):
|
||||
opts = AzSearchOptions(searchterm="hello", limit=5)
|
||||
dumped = opts.model_dump(exclude_none=True)
|
||||
assert dumped["searchterm"] == "hello"
|
||||
assert dumped["limit"] == 5
|
||||
|
||||
def test_search_result_minimal(self):
|
||||
result = SearchResult.model_validate({})
|
||||
assert result.count is None
|
||||
Loading…
Add table
Add a link
Reference in a new issue