From 7b72a2cad22de053acd2fa84d88976fab2414e4a Mon Sep 17 00:00:00 2001 From: Christopher Broderick Date: Mon, 17 Jul 2023 23:33:56 +0100 Subject: [PATCH] Allow identifying what exactly is not asserted. --- helpdesk/tests/test_ticket_submission.py | 25 +++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/helpdesk/tests/test_ticket_submission.py b/helpdesk/tests/test_ticket_submission.py index 2e1da9ac..1d8ef61c 100644 --- a/helpdesk/tests/test_ticket_submission.py +++ b/helpdesk/tests/test_ticket_submission.py @@ -2,15 +2,12 @@ from django.contrib.auth import get_user_model from django.core import mail -from django.core.exceptions import ObjectDoesNotExist -from django.forms import ValidationError from django.test import TestCase from django.test.client import Client from django.urls import reverse import email -from helpdesk.email import create_ticket_cc, object_from_message +from helpdesk.email import object_from_message from helpdesk.models import CustomField, FollowUp, KBCategory, KBItem, Queue, Ticket, TicketCC -from helpdesk.tests.helpers import print_response import logging from urllib.parse import urlparse import uuid @@ -1102,9 +1099,23 @@ class EmailInteractionsTestCase(TestCase): cat_url = reverse('helpdesk:submit') + \ "?kbitem=1&submitter_email=foo@bar.cz&title=lol" response = self.client.get(cat_url) + + if ( + hasattr(response, "render") + and callable(response.render) + and not response.is_rendered + ): + response.render() + if response.streaming: + content = b"".join(response.streaming_content) + else: + content = response.content + + + msg_prefix = content.decode(response.charset) self.assertContains( - response, '') + response, '', msg_prefix = msg_prefix) self.assertContains( - response, '') + response, '', msg_prefix = msg_prefix) self.assertContains( - response, '') + response, '', msg_prefix = msg_prefix)