"""Tests fuer src/models.py - Pydantic-Validierung.""" import pytest from pydantic import ValidationError from models import ( MagicLinkRequest, MagicLinkResponse, VerifyTokenRequest, TokenResponse, OrgCreate, LicenseCreate, UserCreate, ) def test_magic_link_request_accepts_email(): r = MagicLinkRequest(email="info@aegis-sight.de") assert r.email == "info@aegis-sight.de" def test_magic_link_request_rejects_too_short(): with pytest.raises(ValidationError): MagicLinkRequest(email="a") def test_verify_token_min_length(): with pytest.raises(ValidationError): VerifyTokenRequest(token="abc") def test_token_response_default_email_empty(): r = TokenResponse(access_token="x" * 40, username="info") assert r.email == "" assert r.token_type == "bearer" def test_org_create_slug_pattern(): """Slug muss lowercase mit Bindestrichen sein.""" OrgCreate(name="Test", slug="abc-123") with pytest.raises(ValidationError): OrgCreate(name="Test", slug="Wrong Case") with pytest.raises(ValidationError): OrgCreate(name="Test", slug="under_score") def test_license_create_type_pattern(): LicenseCreate(organization_id=1, license_type="trial") LicenseCreate(organization_id=1, license_type="annual") LicenseCreate(organization_id=1, license_type="permanent") with pytest.raises(ValidationError): LicenseCreate(organization_id=1, license_type="lifetime") def test_user_create_role_pattern(): UserCreate(email="a@b.de", role="member") UserCreate(email="a@b.de", role="org_admin") with pytest.raises(ValidationError): UserCreate(email="a@b.de", role="superuser")