(demo) add a "demo" app to facilitate testing/working on the project

We designed it to allow creating a huge number of objects fast using
bulk creation.
This commit is contained in:
Samuel Paccoud - DINUM
2024-01-15 09:18:57 +01:00
committed by Anthony LC
parent cfc35ac23e
commit 0c550ebd1c
9 changed files with 280 additions and 0 deletions

View File

View File

@@ -0,0 +1,32 @@
"""Test the `create_demo` management command"""
from unittest import mock
from django.core.management import call_command
from django.test import override_settings
import pytest
from core import models
from demo import defaults
TEST_NB_OBJECTS = {
"users": 5,
"teams": 3,
"max_identities_per_user": 3,
"max_users_per_team": 5,
}
pytestmark = pytest.mark.django_db
@override_settings(DEBUG=True)
@mock.patch.dict(defaults.NB_OBJECTS, TEST_NB_OBJECTS)
def test_commands_create_demo():
"""The create_demo management command should create objects as expected."""
call_command("create_demo")
assert models.User.objects.count() == 5
assert models.Identity.objects.exists()
assert models.Team.objects.count() == 3
assert models.TeamAccess.objects.count() >= 3