From 9fd170f707e9ad9315c4b75de3cd57b3aa6f821e Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Sun, 16 Jul 2017 19:53:05 -0400 Subject: [PATCH] Add test for num_to_link function --- helpdesk/tests/test_ticket_actions.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/helpdesk/tests/test_ticket_actions.py b/helpdesk/tests/test_ticket_actions.py index 42fd11a8..7f9e23b5 100644 --- a/helpdesk/tests/test_ticket_actions.py +++ b/helpdesk/tests/test_ticket_actions.py @@ -10,6 +10,7 @@ try: # python 3 except ImportError: # python 2 from urlparse import urlparse +from helpdesk.templatetags.ticket_to_link import num_to_link class TicketActionsTestCase(TestCase): fixtures = ['emailtemplate.json'] @@ -121,6 +122,26 @@ class TicketActionsTestCase(TestCase): } response = self.client.post(reverse('helpdesk:update', kwargs={'ticket_id': ticket_id}), post_data, follow=True) self.assertContains(response, 'Changed Status from Open to Closed') + + def test_num_to_link(self): + """Test that we are correctly expanding links to tickets from IDs""" + # make staff user + self.loginUser() + + initial_data = { + 'title': 'Some private ticket', + 'queue': self.queue_public, + 'assigned_to': self.user, + 'status': Ticket.OPEN_STATUS, + } + + # create ticket + ticket = Ticket.objects.create(**initial_data) + ticket_id = ticket.id + + # generate the URL text + result = num_to_link('this is ticket#%s' % ticket_id) + self.assertEqual(result, "this is ticke #%s" % (ticket_id, ticket_id)) def test_create_ticket_getform(self): self.loginUser()