Add flag testmode_supported to sales channels (#1455)

* Add testmode-support-flag to SalesChannels

* Make saleschannels/testmode-warnings even more dangerous!

* Add warning for payment-methods that do support testmode but are being used in a non-testmode order caused by a saleschannel in a testmode-shop.

* Remove redundant testmode_supported-flag for WebshopSalesChannel

* Raise error on API when sales_channel does not support testmode

* Tests

* Fix style issue after merge
This commit is contained in:
Martin Gross
2019-10-21 10:07:02 +02:00
committed by Raphael Michel
parent e8a2f7e349
commit 2b18621c76
14 changed files with 171 additions and 24 deletions

View File

@@ -9,6 +9,7 @@ from django.utils.timezone import now
from django_countries.fields import Country
from django_scopes import scopes_disabled
from pretix.base.channels import SalesChannel
from pretix.base.decimal import round_decimal
from pretix.base.models import (
CartPosition, Event, InvoiceAddress, Item, ItemCategory, ItemVariation,
@@ -24,6 +25,13 @@ from pretix.testutils.scope import classscope
from pretix.testutils.sessions import get_cart_session_key
class FoobarSalesChannel(SalesChannel):
identifier = "bar"
verbose_name = "Foobar"
icon = "home"
testmode_supported = True
class CartTestMixin:
@scopes_disabled()
def setUp(self):
@@ -759,7 +767,7 @@ class CartTest(CartTestMixin, TestCase):
self.ticket.save()
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
'item_%d' % self.ticket.id: '1',
}, follow=True, PRETIX_SALES_CHANNEL='bar')
}, follow=True, PRETIX_SALES_CHANNEL=FoobarSalesChannel)
with scopes_disabled():
self.assertEqual(CartPosition.objects.filter(cart_id=self.session_key, event=self.event).count(), 1)

View File

@@ -12,6 +12,7 @@ from django_scopes import scopes_disabled
from pytz import timezone
from tests.base import SoupTest
from pretix.base.channels import SalesChannel
from pretix.base.models import (
Event, Item, ItemCategory, ItemVariation, Order, Organizer, Quota, Team,
User, WaitingListEntry,
@@ -19,6 +20,13 @@ from pretix.base.models import (
from pretix.base.models.items import SubEventItem, SubEventItemVariation
class FoobarSalesChannel(SalesChannel):
identifier = "bar"
verbose_name = "Foobar"
icon = "home"
testmode_supported = True
class EventTestMixin:
@scopes_disabled()
def setUp(self):
@@ -109,7 +117,7 @@ class ItemDisplayTest(EventTestMixin, SoupTest):
q.items.add(item)
html = self.client.get('/%s/%s/' % (self.orga.slug, self.event.slug)).rendered_content
self.assertNotIn("Early-bird", html)
html = self.client.get('/%s/%s/' % (self.orga.slug, self.event.slug), PRETIX_SALES_CHANNEL="bar").rendered_content
html = self.client.get('/%s/%s/' % (self.orga.slug, self.event.slug), PRETIX_SALES_CHANNEL=FoobarSalesChannel).rendered_content
self.assertIn("Early-bird", html)
def test_timely_available(self):