import pytest
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession

from src.models.user import User
from src.scripts.seed import build_seed_user, seed_database

@pytest.mark.integration
def test_build_seed_user_returns_deterministic_payload() -> None:
    payload = build_seed_user()

    assert payload == {
        "email": "dev@headquarter.local",
        "name": "Development User",
        "authentik_id": "dev-authentik-user",
        "avatar_url": None,
    }


@pytest.mark.asyncio
@pytest.mark.integration
async def test_seed_database_creates_development_user(db_session: AsyncSession) -> None:
    await seed_database(db_session)

    seeded_user = await db_session.scalar(select(User).where(User.email == "dev@headquarter.local"))

    assert seeded_user is not None
    assert seeded_user.authentik_id == "dev-authentik-user"
