from apps.company.models import AboutPage, CompanyValue, ProcessStep, Stat
from apps.company.seed import VALUES, seed


def _counts() -> tuple[int, ...]:
    models = (AboutPage, CompanyValue, ProcessStep, Stat)
    return tuple(model.objects.count() for model in models)


def test_seed_is_idempotent(content):
    before = _counts()
    seed()
    assert _counts() == before == (1, 4, 4, 4)


def test_seed_renames_value_in_place_instead_of_duplicating(content):
    value = CompanyValue.objects.get(order=0)
    value.title = "Ancien titre"
    value.save()
    seed()
    assert CompanyValue.objects.count() == len(VALUES)
    assert CompanyValue.objects.get(pk=value.pk).title == VALUES[0][0]
