from app.db.seed import run_seed
from app.modules.users.repository import get_user_by_email


def test_seed_ensures_admin_is_superuser():
    admin = get_user_by_email("admin@compton.example")
    assert admin is not None
    admin.is_superuser = False
    from app.modules.users import repository

    repository.update_user(admin)

    run_seed(include_demo_pages=False)

    refreshed = get_user_by_email("admin@compton.example")
    assert refreshed is not None
    assert refreshed.is_superuser is True


def test_seed_ensures_ops_is_not_superuser():
    ops = get_user_by_email("ops@compton.example")
    assert ops is not None
    ops.is_superuser = True
    from app.modules.users import repository

    repository.update_user(ops)

    run_seed(include_demo_pages=False)

    refreshed = get_user_by_email("ops@compton.example")
    assert refreshed is not None
    assert refreshed.is_superuser is False
