Fix tests for users.User idiom

This commit is contained in:
Klaas van Schelven
2024-06-12 17:45:06 +02:00
parent 152c5b5204
commit c4358aaece
3 changed files with 11 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
from django.test import TestCase as DjangoTestCase
from django.core import mail
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from django.template.loader import get_template
from issues.factories import get_or_create_issue
@@ -11,6 +11,8 @@ from events.factories import create_event
from .tasks import send_new_issue_alert, send_regression_alert, send_unmute_alert
from .views import DEBUG_CONTEXTS
User = get_user_model()
class TestAlertSending(DjangoTestCase):
@@ -67,8 +69,8 @@ class TestAlertSending(DjangoTestCase):
def test_txt_and_html_have_relevant_variables_defined(self):
example_context = DEBUG_CONTEXTS["issue_alert"]
html_template = get_template("alerts/issue_alert.html")
text_template = get_template("alerts/issue_alert.txt")
html_template = get_template("mails/issue_alert.html")
text_template = get_template("mails/issue_alert.txt")
unused_in_text = [
"base_url", # link to the site is not included at the top of the text template

View File

@@ -1,7 +1,7 @@
import datetime
from django.test import TestCase as DjangoTestCase, TransactionTestCase
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from django.conf import settings
from django.utils import timezone
@@ -11,6 +11,8 @@ from issues.factories import denormalized_issue_fields
from .factories import create_event
User = get_user_model()
class ViewTests(TransactionTestCase):
# we start with minimal "does this show something and not fully crash" tests and will expand from there.

View File

@@ -8,7 +8,7 @@ from unittest.mock import patch
from datetime import datetime, timezone
from django.test import TestCase as DjangoTestCase, TransactionTestCase
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
from django.test import tag
from projects.models import Project, ProjectMembership
@@ -25,6 +25,8 @@ from .regressions import is_regression, is_regression_2, issue_is_regression
from .factories import denormalized_issue_fields
from .utils import get_issue_grouper_for_data
User = get_user_model()
def fresh(obj):
return type(obj).objects.get(pk=obj.pk)