Add test for num_to_link function

This commit is contained in:
Garret Wassermann 2017-07-16 19:53:05 -04:00
parent a42a5b8aeb
commit 9fd170f707

View File

@ -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 <a href='/helpdesk/tickets/%s/' class='ticket_link_status ticket_link_status_Open'>#%s</a>" % (ticket_id, ticket_id))
def test_create_ticket_getform(self):
self.loginUser()