✨(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:
committed by
Anthony LC
parent
cfc35ac23e
commit
0c550ebd1c
0
src/backend/demo/tests/__init__.py
Normal file
0
src/backend/demo/tests/__init__.py
Normal file
32
src/backend/demo/tests/test_commands_create_demo.py
Normal file
32
src/backend/demo/tests/test_commands_create_demo.py
Normal 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
|
||||
Reference in New Issue
Block a user