✅(backend) override defaults.NB_OBJECTS for the demo tests
Otherwise when you increase the number of objects to test how the application scales, the demo test will take too long...
This commit is contained in:
committed by
Anthony LC
parent
7b39b3f7f6
commit
2e8a399668
@@ -1,4 +1,5 @@
|
||||
"""Test the `create_demo` management command"""
|
||||
from unittest import mock
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.test import override_settings
|
||||
@@ -10,15 +11,20 @@ from core import models
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
@mock.patch("demo.defaults.NB_OBJECTS", {
|
||||
"users": 10,
|
||||
"docs": 10,
|
||||
"max_users_per_document": 5,
|
||||
} )
|
||||
@override_settings(DEBUG=True)
|
||||
def test_commands_create_demo():
|
||||
"""The create_demo management command should create objects as expected."""
|
||||
call_command("create_demo")
|
||||
|
||||
assert models.Template.objects.count() == 1
|
||||
assert models.User.objects.count() >= 50
|
||||
assert models.Document.objects.count() >= 50
|
||||
assert models.DocumentAccess.objects.count() > 50
|
||||
assert models.User.objects.count() >= 10
|
||||
assert models.Document.objects.count() >= 10
|
||||
assert models.DocumentAccess.objects.count() > 10
|
||||
|
||||
# assert dev users have doc accesses
|
||||
user = models.User.objects.get(email="impress@impress.world")
|
||||
|
||||
Reference in New Issue
Block a user