Add safeguards and tests against duplicate cancellations

This commit is contained in:
Raphael Michel
2019-10-24 16:07:34 +02:00
parent fe92af10fb
commit 3f5e835367
4 changed files with 30 additions and 1 deletions

View File

@@ -213,6 +213,28 @@ def test_expiring_paid_invoice(event):
assert o2.invoices.last().is_cancellation is False
@pytest.mark.django_db
def test_expire_twice(event):
o2 = Order.objects.create(
code='FO2', event=event, email='dummy@dummy.test',
status=Order.STATUS_PENDING, locale='en',
datetime=now(), expires=now() - timedelta(days=10),
total=12,
)
generate_invoice(o2)
expire_orders(None)
o2 = Order.objects.get(id=o2.id)
assert o2.status == Order.STATUS_EXPIRED
assert o2.invoices.count() == 2
# this would usually happen when the deadline is extended, but lets keep the case simple
o2.status = Order.STATUS_PENDING
o2.save()
expire_orders(None)
o2 = Order.objects.get(id=o2.id)
assert o2.status == Order.STATUS_EXPIRED
assert o2.invoices.count() == 2
@pytest.mark.django_db
def test_expiring_auto_disabled(event):
event.settings.set('payment_term_expire_automatically', False)