kfet -- Create initial statement on checkout save

- Why? Because it should be the actual behavior.
- To allow using arithmetic operations with values of DecimalField when
object are not retrieved from DB, some strings are replaced by Decimal
or int.
If you wonder why it's not automatically done, see:
https://code.djangoproject.com/ticket/27825
This commit is contained in:
Aurélien Delobelle 2018-01-16 15:59:17 +01:00
parent 44eee9be38
commit 478f56d94b
4 changed files with 65 additions and 17 deletions

View file

@ -746,12 +746,16 @@ class CheckoutReadViewTests(ViewTestCaseMixin, TestCase):
def setUp(self):
super().setUp()
self.checkout = Checkout.objects.create(
name='Checkout',
created_by=self.accounts['team'],
valid_from=self.now,
valid_to=self.now + timedelta(days=5),
)
with mock.patch('django.utils.timezone.now') as mock_now:
mock_now.return_value = self.now
self.checkout = Checkout.objects.create(
name='Checkout', balance=Decimal('10'),
created_by=self.accounts['team'],
valid_from=self.now,
valid_to=self.now + timedelta(days=1),
)
def test_ok(self):
r = self.client.get(self.url)
@ -794,7 +798,7 @@ class CheckoutUpdateViewTests(ViewTestCaseMixin, TestCase):
name='Checkout',
valid_from=self.now,
valid_to=self.now + timedelta(days=5),
balance='3.14',
balance=Decimal('3.14'),
is_protected=False,
created_by=self.accounts['team'],
)
@ -864,6 +868,7 @@ class CheckoutStatementListViewTests(ViewTestCaseMixin, TestCase):
self.assertQuerysetEqual(
r.context['checkoutstatements'],
map(repr, expected_statements),
ordered=False,
)