From 1df04d2131bcc5207c09f93c5bcad54310207c0b Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 2 Sep 2026 12:30:29 +0200 Subject: [PATCH] Add tests --- src/tests/presale/test_checkout.py | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/tests/presale/test_checkout.py b/src/tests/presale/test_checkout.py index 15f99f030e..9411a4ad8c 100644 --- a/src/tests/presale/test_checkout.py +++ b/src/tests/presale/test_checkout.py @@ -2372,6 +2372,39 @@ class CheckoutTestCase(BaseCheckoutTestCase, TimemachineTestMixin, TestCase): assert p2.fee.value == Decimal("0.46") assert o.total == Decimal("25.76") + def test_payment_postpone_not_allowed(self): + self.event.settings.set('payment_banktransfer__enabled', True) + with scopes_disabled(): + CartPosition.objects.create( + event=self.event, cart_id=self.session_key, item=self.ticket, + price=23, expires=now() + timedelta(minutes=10) + ) + response = self.client.post('/%s/%s/checkout/payment/' % (self.orga.slug, self.event.slug), { + 'postpone': 'on', + }, follow=False) + assert 'Please select' in response.content.decode() + + def test_payment_postpone_allowed(self): + self.event.settings.set('payment_banktransfer__enabled', True) + self.event.settings.payment_choice_postpone_allowed_channels = ['web'] + with scopes_disabled(): + CartPosition.objects.create( + event=self.event, cart_id=self.session_key, item=self.ticket, + price=23, expires=now() + timedelta(minutes=10) + ) + response = self.client.post('/%s/%s/checkout/payment/' % (self.orga.slug, self.event.slug), { + 'postpone': 'on', + }, follow=True) + self.assertRedirects(response, '/%s/%s/checkout/confirm/' % (self.orga.slug, self.event.slug), + target_status_code=200) + + response = self.client.post('/%s/%s/checkout/confirm/' % (self.orga.slug, self.event.slug), follow=True) + doc = BeautifulSoup(response.content.decode(), "lxml") + self.assertEqual(len(doc.select(".thank-you")), 1) + with scopes_disabled(): + o = Order.objects.last() + assert not o.payments.exists() + def test_premature_confirm(self): response = self.client.get('/%s/%s/checkout/confirm/' % (self.orga.slug, self.event.slug), follow=True) self.assertRedirects(response, '/%s/%s/?require_cookie=true' % (self.orga.slug, self.event.slug),