From 7e15fd2d9ed020aa76273bb329ef7bac88fb095f Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Wed, 18 Jul 2018 16:37:41 +0200 Subject: [PATCH] Fix CheckoutReadView test --- kfet/tests/test_views.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/kfet/tests/test_views.py b/kfet/tests/test_views.py index ea70ddc0..637e30ea 100644 --- a/kfet/tests/test_views.py +++ b/kfet/tests/test_views.py @@ -4,6 +4,7 @@ from decimal import Decimal from unittest import mock from django.contrib.auth.models import Group +from django.core.serializers.json import DjangoJSONEncoder from django.core.urlresolvers import reverse from django.test import Client, TestCase from django.utils import timezone @@ -790,18 +791,23 @@ class CheckoutReadViewTests(ViewTestCaseMixin, TestCase): self.assertEqual(r.status_code, 200) 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, { 'id': self.checkout.pk, 'name': 'Checkout', - 'balance': '0.00', - 'valid_from': '2018-01-12T16:20:00Z', - 'valid_to': '2018-01-17T16:20:00Z', + 'balance': '10.00', + 'valid_from': json_now, + 'valid_to': json_tomorrow, 'laststatement': { 'id': self.checkout.statements.all()[0].pk, - 'at': '2018-01-12T16:20:00Z', - 'balance_new': '0.00', - 'balance_old': '0.00', + 'at': json_now, + 'balance_new': '10.00', + 'balance_old': '10.00', 'by': str(self.accounts['team']), }, })