This commit is contained in:
j3d1 2024-07-18 20:32:31 +02:00
parent add8e4fa67
commit 2d4e5a89fb
3 changed files with 63 additions and 7 deletions

View file

@ -8,6 +8,8 @@ from tickets.models import IssueThread, StateChange, Comment
from django.contrib.auth.models import Permission
from knox.models import AuthToken
from base64 import b64encode
class IssueApiTest(TestCase):
@ -230,7 +232,7 @@ class IssueApiTest(TestCase):
self.assertEqual(file2.hash, response.json()[0]['timeline'][1]['attachments'][1]['hash'])
def test_manual_creation(self):
response = self.client.post('/api/2/tickets/manual/',
response = self.client.post('/api/2/evt/tickets/manual/',
{'name': 'test issue', 'sender': 'test', 'recipient': 'test', 'body': 'test'},
content_type='application/json')
self.assertEqual(response.status_code, 201)
@ -247,7 +249,7 @@ class IssueApiTest(TestCase):
self.assertEqual(timeline[1]['subject'], 'test issue')
self.assertEqual(timeline[1]['body'], 'test')
#def test_post_comment(self):
# def test_post_comment(self):
# issue = IssueThread.objects.create(
# name="test issue",
# )
@ -315,3 +317,20 @@ class IssueApiTest(TestCase):
self.assertEqual('pending_new', timeline[0]['state'])
self.assertEqual('assignment', timeline[1]['type'])
self.assertEqual(self.user.username, timeline[1]['assigned_to'])
class IssueSearchTest(TestCase):
def setUp(self):
super().setUp()
self.user = ExtendedUser.objects.create_user('testuser', 'test', 'test')
self.user.user_permissions.add(*Permission.objects.all())
self.user.save()
self.token = AuthToken.objects.create(user=self.user)
self.client = Client(headers={'Authorization': 'Token ' + self.token[1]})
def test_search(self):
search_query = b64encode(b'abc').decode('utf-8')
response = self.client.get(f'/api/2/evt/tickets/{search_query}/')
self.assertEqual(200, response.status_code)
self.assertEqual([], response.json())