initial commit after automated creating
This commit is contained in:
commit
1cf124a5a3
48 changed files with 12041 additions and 0 deletions
1
tests/__init__.py
Normal file
1
tests/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
# tests package
|
||||
31
tests/conftest.py
Normal file
31
tests/conftest.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
"""Shared pytest fixtures for the agravity-client test suite."""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
import httpx
|
||||
|
||||
from agravity_client.client import AgravityClient
|
||||
from agravity_client.config import AgravityConfig
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def config() -> AgravityConfig:
|
||||
"""Return a test AgravityConfig with a dummy API key."""
|
||||
return AgravityConfig(
|
||||
api_key="test-api-key",
|
||||
base_url="https://api.example.local/api",
|
||||
)
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def client(config: AgravityConfig) -> AgravityClient:
|
||||
"""Return an AgravityClient backed by a real (but not-yet-connected) transport.
|
||||
|
||||
Tests that need to mock HTTP responses should use ``pytest-httpx``'s
|
||||
``httpx_mock`` fixture and pass a transport via::
|
||||
|
||||
client._http = httpx.AsyncClient(transport=httpx_mock.get_async_handler())
|
||||
"""
|
||||
async with AgravityClient(config) as c:
|
||||
yield c
|
||||
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