stash
This commit is contained in:
parent
39ce06d180
commit
9c3fedc5c3
3 changed files with 43 additions and 1 deletions
|
@ -29,7 +29,7 @@ class StateSerializer(serializers.Serializer):
|
||||||
return obj['value']
|
return obj['value']
|
||||||
|
|
||||||
|
|
||||||
class ShippingCodeSerializer(serializers.Serializer):
|
class ShippingCodeSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ShippingCode
|
model = ShippingCode
|
||||||
fields = ('id', 'code', 'timestamp', 'issue_thread', 'used_at')
|
fields = ('id', 'code', 'timestamp', 'issue_thread', 'used_at')
|
||||||
|
|
32
core/tickets/tests/v2/test_shipping_codes.py
Normal file
32
core/tickets/tests/v2/test_shipping_codes.py
Normal file
|
@ -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)
|
|
@ -247,6 +247,16 @@ class IssueApiTest(TestCase):
|
||||||
self.assertEqual(timeline[1]['subject'], 'test issue')
|
self.assertEqual(timeline[1]['subject'], 'test issue')
|
||||||
self.assertEqual(timeline[1]['body'], 'test')
|
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):
|
def test_post_comment_altenative(self):
|
||||||
issue = IssueThread.objects.create(
|
issue = IssueThread.objects.create(
|
||||||
name="test issue",
|
name="test issue",
|
||||||
|
|
Loading…
Reference in a new issue