This commit is contained in:
j3d1 2024-06-18 17:00:52 +02:00
parent 8ac7b91ba8
commit cc630ae03c
2 changed files with 5 additions and 5 deletions

View file

@ -32,7 +32,7 @@ class StateSerializer(serializers.Serializer):
class ShippingVoucherSerializer(serializers.ModelSerializer):
class Meta:
model = ShippingVoucher
fields = ('id', 'code', 'type', 'timestamp', 'issue_thread', 'used_at')
fields = ('id', 'voucher', 'type', 'timestamp', 'issue_thread', 'used_at')
read_only_fields = ('id', 'timestamp', 'used_at')

View file

@ -25,17 +25,17 @@ class ShippingVoucherApiTest(TestCase):
self.assertEqual(response.json(), [])
def test_issues_list(self):
ShippingVoucher.objects.create(code='1234', type='2kg-eu')
ShippingVoucher.objects.create(voucher='1234', type='2kg-eu')
response = self.client.get('/api/2/shipping_vouchers/')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()[0]['code'], '1234')
self.assertEqual(response.json()[0]['voucher'], '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_vouchers/', {'code': '1234', 'type': '2kg-eu'})
response = self.client.post('/api/2/shipping_vouchers/', {'voucher': '1234', 'type': '2kg-eu'})
self.assertEqual(response.status_code, 201)
self.assertEqual(response.json()['code'], '1234')
self.assertEqual(response.json()['voucher'], '1234')
self.assertEqual(response.json()['used_at'], None)
self.assertEqual(response.json()['issue_thread'], None)