Files
kite/backend/tests/test_task1_models_config.py
T
curo1305 fac0e781f9 test(07.3-01): extend test_settings_has_jwt_config — red until Plan 02
- Assert settings.refresh_token_expire_hours == 16 (CFG-01 / D-09)
- Assert hasattr(settings, "jwt_private_key") (CFG-01 / D-01)
- Assert hasattr(settings, "jwt_public_key") (CFG-01 / D-01)
- Existing refresh_token_expire_days == 30 assertion preserved (Pitfall 5)
- Test intentionally fails until Plan 02 adds the three new config fields
2026-06-06 16:50:32 +02:00

76 lines
2.5 KiB
Python

"""
TDD tests for Task 1: BackupCode ORM model, password_must_change field, Settings extension.
These tests should FAIL before implementation (RED phase).
"""
import pytest
def test_backup_code_model_exists():
"""BackupCode ORM model must exist and have correct tablename + columns."""
from db.models import BackupCode
assert BackupCode.__tablename__ == "backup_codes"
assert hasattr(BackupCode, "id")
assert hasattr(BackupCode, "user_id")
assert hasattr(BackupCode, "code_hash")
assert hasattr(BackupCode, "used_at")
def test_user_has_password_must_change():
"""User model must have password_must_change column."""
from db.models import User
assert hasattr(User, "password_must_change")
def test_settings_has_jwt_config():
"""Settings must have access_token_expire_minutes and refresh_token_expire_days."""
from config import settings
assert hasattr(settings, "access_token_expire_minutes")
assert settings.access_token_expire_minutes == 15
assert hasattr(settings, "refresh_token_expire_days")
assert settings.refresh_token_expire_days == 30
assert hasattr(settings, "refresh_token_expire_hours")
assert settings.refresh_token_expire_hours == 16
assert hasattr(settings, "jwt_private_key")
assert hasattr(settings, "jwt_public_key")
def test_settings_has_smtp_config():
"""Settings must have SMTP fields."""
from config import settings
assert hasattr(settings, "smtp_host")
assert hasattr(settings, "smtp_port")
assert hasattr(settings, "smtp_user")
assert hasattr(settings, "smtp_password")
assert hasattr(settings, "smtp_from")
def test_settings_has_admin_config():
"""Settings must have admin bootstrap fields."""
from config import settings
assert hasattr(settings, "admin_email")
assert hasattr(settings, "admin_password")
def test_settings_has_cors_origins():
"""Settings must have cors_origins as a list with default localhost."""
from config import settings
assert hasattr(settings, "cors_origins")
assert isinstance(settings.cors_origins, list)
assert "http://localhost:5173" in settings.cors_origins
def test_backup_code_table_in_schema(db_session):
"""backup_codes table must be created in the SQLite test schema."""
from db.models import BackupCode
import uuid
# Should not raise — table must exist
bc = BackupCode(
id=uuid.uuid4(),
user_id=uuid.uuid4(),
code_hash="testhash",
used_at=None,
)
db_session.add(bc)
# We don't commit here — just verify the model is valid