Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed submissions not working on dev env #86

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ensure that test doesn't autocreate users before
  • Loading branch information
JasonGrace2282 committed Jan 11, 2025
commit 21e23d7fabd2afbeffa18eccf52d4fbaef1cc747
17 changes: 14 additions & 3 deletions tin/apps/users/tests.py
Original file line number Diff line number Diff line change
@@ -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()
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
Loading