To be able to test with dummy data, we need to create our dev users from the demo and to give them access to the docs. The sub is the unicity of the user for our oidc provider, so we need to know the sub to be able to create correctly the user, it is why we set the sub as the email of the user in the realm.json file.
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
"""Test the `create_demo` management command"""
|
|
|
|
from django.core.management import call_command
|
|
from django.test import override_settings
|
|
|
|
import pytest
|
|
|
|
from core import models
|
|
|
|
pytestmark = pytest.mark.django_db
|
|
|
|
|
|
@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 dev users have doc accesses
|
|
user = models.User.objects.get(email="impress@impress.world")
|
|
assert models.DocumentAccess.objects.filter(user=user).exists()
|
|
user = models.User.objects.get(email="user@webkit.e2e")
|
|
assert models.DocumentAccess.objects.filter(user=user).exists()
|
|
user = models.User.objects.get(email="user@firefox.e2e")
|
|
assert models.DocumentAccess.objects.filter(user=user).exists()
|
|
user = models.User.objects.get(email="user@chromium.e2e")
|
|
assert models.DocumentAccess.objects.filter(user=user).exists()
|