From 07f6d5f6c8cc44337e4c6ce9aa726a4dad16aa6c Mon Sep 17 00:00:00 2001 From: Christopher Broderick Date: Tue, 18 Jul 2023 01:01:10 +0100 Subject: [PATCH] Make test less dependent on template changes --- helpdesk/tests/test_ticket_submission.py | 27 +++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/helpdesk/tests/test_ticket_submission.py b/helpdesk/tests/test_ticket_submission.py index 1d8ef61c..2c59ef75 100644 --- a/helpdesk/tests/test_ticket_submission.py +++ b/helpdesk/tests/test_ticket_submission.py @@ -1085,21 +1085,32 @@ class EmailInteractionsTestCase(TestCase): cat = KBCategory.objects.create( title="Test Cat", slug="test_cat", - description="This is a test category", + description="This is a test category", queue=self.queue_public, ) cat.save() + attr_list = { + "f1_field_title": "KBItem 1", + "f1_attr": "kbitem", + "f1_attr_value": "1", + "f2_attr": "submitter_email", + "f2_attr_value": "foo@bar.cz", + "f3_attr": "title", + "f3_attr_value": "lol", + } self.kbitem1 = KBItem.objects.create( category=cat, - title="KBItem 1", + title=attr_list["f1_field_title"], question="What?", answer="A KB Item", ) self.kbitem1.save() - cat_url = reverse('helpdesk:submit') + \ - "?kbitem=1&submitter_email=foo@bar.cz&title=lol" + cat_url = reverse('helpdesk:submit') + '?' \ + + attr_list["f1_attr"] + '=' + attr_list["f1_attr_value"] + '&' \ + + attr_list["f2_attr"] + '=' + attr_list["f2_attr_value"] + '&' \ + + attr_list["f3_attr"] + '=' + attr_list["f3_attr_value"] response = self.client.get(cat_url) - + # Get the rendered response to make it easier to debug if things go wrong if ( hasattr(response, "render") and callable(response.render) @@ -1114,8 +1125,8 @@ class EmailInteractionsTestCase(TestCase): msg_prefix = content.decode(response.charset) self.assertContains( - response, '', msg_prefix = msg_prefix) + response, '', msg_prefix = msg_prefix) self.assertContains( - response, '', msg_prefix = msg_prefix) + response, '', msg_prefix = msg_prefix) + response, '