This commit is contained in:
j3d1 2024-06-18 14:15:29 +02:00
parent 4799a7cd5d
commit 69ce11c331
4 changed files with 50 additions and 26 deletions

View file

@ -4,7 +4,7 @@ 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 tickets.models import IssueThread, StateChange, Comment, ShippingCode
from django.contrib.auth.models import Permission
from knox.models import AuthToken
@ -24,8 +24,17 @@ class ShippingCodeApiTest(TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), [])
def test_issues_list(self):
ShippingCode.objects.create(code='1234', type='2kg-eu')
response = self.client.get('/api/2/shipping_codes/')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()[0]['code'], '1234')
self.assertEqual(response.json()[0]['used_at'], None)
self.assertEqual(response.json()[0]['issue_thread'], None)
self.assertEqual(response.json()[0]['type'], '2kg-eu')
def test_issues_create(self):
response = self.client.post('/api/2/shipping_codes/', {'code': '1234'})
response = self.client.post('/api/2/shipping_codes/', {'code': '1234', 'type': '2kg-eu'})
self.assertEqual(response.status_code, 201)
self.assertEqual(response.json()['code'], '1234')
self.assertEqual(response.json()['used_at'], None)