diff --git a/tin/apps/users/tests.py b/tin/apps/users/tests.py index 8e6b7071..33f65f22 100644 --- a/tin/apps/users/tests.py +++ b/tin/apps/users/tests.py @@ -1,11 +1,22 @@ from __future__ import annotations +import pytest from django.contrib.auth import get_user_model from django.core.management import call_command +@pytest.mark.no_autocreate_users def test_create_debug_users(): + admin = get_user_model().objects.filter(username="admin", is_superuser=True) + student = get_user_model().objects.filter(username="student", is_student=True) + teacher = get_user_model().objects.filter(username="teacher", is_teacher=True) + + assert not admin.exists() + assert not teacher.exists() + assert not student.exists() + call_command("create_debug_users", noinput=True, verbosity=0) - assert get_user_model().objects.filter(username="admin", is_superuser=True) - assert get_user_model().objects.filter(username="student", is_student=True) - assert get_user_model().objects.filter(username="teacher", is_teacher=True) + + assert admin.exists() + assert teacher.exists() + assert student.exists() diff --git a/tin/tests/fixtures.py b/tin/tests/fixtures.py index 2cd66aa3..a89bf6c7 100644 --- a/tin/tests/fixtures.py +++ b/tin/tests/fixtures.py @@ -33,8 +33,10 @@ def tin_setup(settings, worker_id: str, testrun_uid: str): @pytest.fixture(autouse=True) -def create_users(): - users.add_users_to_database(password=PASSWORD, verbose=False) +def create_users(request): + marker = request.node.get_closest_marker("no_autocreate_users") + if marker is None: + users.add_users_to_database(password=PASSWORD, verbose=False) @pytest.fixture