From 3260eefc66cb6a42cdf2e63942c765067b85007d Mon Sep 17 00:00:00 2001 From: jedi Date: Sat, 15 Jun 2024 19:27:20 +0200 Subject: [PATCH] stash --- core/tickets/tests/v2/test_shipping_codes.py | 32 ++++++++++++++++++++ core/tickets/tests/v2/test_tickets.py | 10 ++++++ 2 files changed, 42 insertions(+) create mode 100644 core/tickets/tests/v2/test_shipping_codes.py diff --git a/core/tickets/tests/v2/test_shipping_codes.py b/core/tickets/tests/v2/test_shipping_codes.py new file mode 100644 index 0000000..7c64460 --- /dev/null +++ b/core/tickets/tests/v2/test_shipping_codes.py @@ -0,0 +1,32 @@ +from datetime import datetime, timedelta + +from django.test import TestCase, Client + +from authentication.models import ExtendedUser +from mail.models import Email, EmailAttachment +from tickets.models import IssueThread, StateChange, Comment +from django.contrib.auth.models import Permission +from knox.models import AuthToken + + +class ShippingCodeApiTest(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_issues_empty(self): + response = self.client.get('/api/2/shipping_codes/') + self.assertEqual(response.status_code, 200) + self.assertEqual(response.json(), []) + + def test_issues_create(self): + response = self.client.post('/api/2/shipping_codes/', {'code': '1234'}) + self.assertEqual(response.status_code, 201) + self.assertEqual(response.json()['code'], '1234') + self.assertEqual(response.json()['used_at'], None) + self.assertEqual(response.json()['issue_thread'], None) diff --git a/core/tickets/tests/v2/test_tickets.py b/core/tickets/tests/v2/test_tickets.py index 8223506..0fea3dc 100644 --- a/core/tickets/tests/v2/test_tickets.py +++ b/core/tickets/tests/v2/test_tickets.py @@ -247,6 +247,16 @@ class IssueApiTest(TestCase): self.assertEqual(timeline[1]['subject'], 'test issue') self.assertEqual(timeline[1]['body'], 'test') + #def test_post_comment(self): + # issue = IssueThread.objects.create( + # name="test issue", + # ) + # response = self.client.post('/api/2/comments/', {'comment': 'test', 'issue_thread': issue.id}) + # self.assertEqual(response.status_code, 201) + # self.assertEqual(response.json()['comment'], 'test') + # self.assertEqual(response.json()['issue_thread'], issue.id) + # self.assertEqual(response.json()['timestamp'], response.json()['timestamp']) + def test_post_comment_altenative(self): issue = IssueThread.objects.create( name="test issue",