django-helpdeskmig/helpdesk/tests/test_savequery.py

31 lines
1.0 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
from django.urls import reverse
from django.test import TestCase
2016-10-21 17:14:12 +02:00
from helpdesk.models import Queue
2019-03-20 13:47:57 +01:00
from helpdesk.tests.helpers import get_user
2016-10-21 17:14:12 +02:00
class TestSavingSharedQuery(TestCase):
def setUp(self):
q = Queue(title='Q1', slug='q1')
q.save()
self.q = q
def test_cansavequery(self):
"""Can a query be saved"""
2016-10-19 15:30:37 +02:00
url = reverse('helpdesk:savequery')
2019-03-20 13:47:57 +01:00
self.client.login(username=get_user(is_staff=True).get_username(),
password='password')
2016-10-21 17:14:12 +02:00
response = self.client.post(
url,
data={
'title': 'ticket on my queue',
'queue': self.q,
'shared': 'on',
'query_encoded':
'KGRwMApWZmlsdGVyaW5nCnAxCihkcDIKVnN0YXR1c19faW4KcDMKKG'
'xwNApJMQphSTIKYUkzCmFzc1Zzb3J0aW5nCnA1ClZjcmVhdGVkCnA2CnMu'
})
self.assertEqual(response.status_code, 302)
self.assertTrue('tickets/?saved_query=1' in response.url)