booklooker_client/tests/test_models.py
claudi 1d8ee1bba6 feat: Add Booklooker client configuration and exception handling
- Introduced BooklookerConfig class for runtime configuration management.
- Created custom exceptions for API errors, including authentication and validation errors.
- Generated API contracts from OpenAPI specification, including endpoints and security schemes.
- Implemented models for articles, orders, and webhooks to facilitate data handling.
- Developed a webhook helper for processing and enriching webhook events.
- Added tests for configuration defaults, token expiration, and webhook enrichment.
2026-04-16 14:42:19 +02:00

27 lines
974 B
Python

from booklooker_client import BooklookerConfig, SyncBooklookerClient
from booklooker_client.models import ArticleField, ArticleList, ArticleListItem, AuthToken
def test_config_defaults() -> None:
config = BooklookerConfig(api_key="demo")
assert config.base_url == "https://api.booklooker.de/2.0"
assert config.timeout > 0
def test_auth_token_not_immediately_expired() -> None:
token = AuthToken(token="abc", expires_after_seconds=600)
assert token.expired is False
def test_article_list_model() -> None:
article_list = ArticleList(items=[ArticleListItem(value="ABC-1")], field=ArticleField.ORDER_NO)
assert article_list.items[0].value == "ABC-1"
def test_client_exposes_generated_endpoints() -> None:
client = SyncBooklookerClient(BooklookerConfig(api_key="demo"))
try:
assert "POST /authenticate" in client.available_endpoints
assert "GET /order" in client.available_endpoints
finally:
client.close()