Only allow restricting payment countries if invoice address is obligatory

This commit is contained in:
Raphael Michel
2018-10-31 15:21:07 +01:00
parent 863165caaa
commit b8669503fa
2 changed files with 38 additions and 9 deletions

View File

@@ -731,13 +731,38 @@ class CheckoutTestCase(TestCase):
doc = BeautifulSoup(response.rendered_content, "lxml")
assert doc.select(".alert-danger")
def test_payment_country_ignored_without_invoice_address_required(self):
self.event.settings.set('payment_stripe__enabled', True)
self.event.settings.set('payment_banktransfer__restricted_countries', ['DE', 'AT'])
self.event.settings.set('payment_banktransfer__enabled', True)
self.event.settings.set('invoice_address_required', False)
ia = InvoiceAddress.objects.create(
is_business=True, vat_id='ATU1234567', vat_id_validated=True,
country=Country('CH')
)
self._set_session('invoice_address', ia.pk)
CartPosition.objects.create(
event=self.event, cart_id=self.session_key, item=self.ticket,
price=23, expires=now() + timedelta(minutes=10)
)
response = self.client.get('/%s/%s/checkout/payment/' % (self.orga.slug, self.event.slug), follow=True)
doc = BeautifulSoup(response.rendered_content, "lxml")
self.assertEqual(len(doc.select('input[name=payment]')), 2)
response = self.client.post('/%s/%s/checkout/payment/' % (self.orga.slug, self.event.slug), {
'payment': 'banktransfer'
}, follow=True)
self.assertEqual(response.status_code, 200)
doc = BeautifulSoup(response.rendered_content, "lxml")
assert not doc.select(".alert-danger")
def test_payment_country_allowed(self):
self.event.settings.set('payment_stripe__enabled', True)
self.event.settings.set('payment_banktransfer__restricted_countries', ['DE', 'AT'])
self.event.settings.set('payment_banktransfer__enabled', True)
self.event.settings.set('invoice_address_required', True)
ia = InvoiceAddress.objects.create(
is_business=True, vat_id='ATU1234567', vat_id_validated=True,
country=Country('DE')
country=Country('DE'), name='Foo', street='Foo'
)
self._set_session('invoice_address', ia.pk)
CartPosition.objects.create(
@@ -758,9 +783,10 @@ class CheckoutTestCase(TestCase):
self.event.settings.set('payment_stripe__enabled', True)
self.event.settings.set('payment_banktransfer__restricted_countries', ['DE', 'AT'])
self.event.settings.set('payment_banktransfer__enabled', True)
self.event.settings.set('invoice_address_required', True)
ia = InvoiceAddress.objects.create(
is_business=True, vat_id='ATU1234567', vat_id_validated=True,
country=Country('CH')
country=Country('CH'), name='Foo', street='Foo'
)
self._set_session('invoice_address', ia.pk)
CartPosition.objects.create(