This commit is contained in:
j3d1 2024-06-18 14:15:29 +02:00
parent 4affc9e8b9
commit 20a1ba8d9d
2 changed files with 21 additions and 11 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)