Skip to content

Commit

Permalink
Ensure that test doesn't autocreate users before
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Nov 10, 2024
1 parent 749f76a commit dc1dc32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions tin/apps/users/tests.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
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():
assert not get_user_model().objects.filter(username="admin", is_superuser=True)
assert not get_user_model().objects.filter(username="student", is_student=True)
assert not get_user_model().objects.filter(username="teacher", is_teacher=True)
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)
Expand Down
6 changes: 4 additions & 2 deletions tin/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dc1dc32

Please sign in to comment.