Fix CheckoutReadView test

This commit is contained in:
Ludovic Stephan 2018-07-18 16:37:41 +02:00
parent a0bd437250
commit 7e15fd2d9e

View file

@ -4,6 +4,7 @@ from decimal import Decimal
from unittest import mock from unittest import mock
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from django.core.serializers.json import DjangoJSONEncoder
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.test import Client, TestCase from django.test import Client, TestCase
from django.utils import timezone from django.utils import timezone
@ -790,18 +791,23 @@ class CheckoutReadViewTests(ViewTestCaseMixin, TestCase):
self.assertEqual(r.status_code, 200) self.assertEqual(r.status_code, 200)
content = json.loads(r.content.decode('utf-8')) content = json.loads(r.content.decode('utf-8'))
json_now = json.dumps(self.now, cls=DjangoJSONEncoder).strip('"')
json_tomorrow = json.dumps(
self.now + timedelta(days=1),
cls=DjangoJSONEncoder
).strip('"')
self.assertEqual(content, { self.assertEqual(content, {
'id': self.checkout.pk, 'id': self.checkout.pk,
'name': 'Checkout', 'name': 'Checkout',
'balance': '0.00', 'balance': '10.00',
'valid_from': '2018-01-12T16:20:00Z', 'valid_from': json_now,
'valid_to': '2018-01-17T16:20:00Z', 'valid_to': json_tomorrow,
'laststatement': { 'laststatement': {
'id': self.checkout.statements.all()[0].pk, 'id': self.checkout.statements.all()[0].pk,
'at': '2018-01-12T16:20:00Z', 'at': json_now,
'balance_new': '0.00', 'balance_new': '10.00',
'balance_old': '0.00', 'balance_old': '10.00',
'by': str(self.accounts['team']), 'by': str(self.accounts['team']),
}, },
}) })