Move testdummy plugin to the test directory

This commit is contained in:
Raphael Michel
2015-06-03 18:14:05 +02:00
parent fad8605aa7
commit 6c3df1e3f5
7 changed files with 12 additions and 8 deletions

View File

@@ -49,9 +49,9 @@ class PluginSignalTest(TestCase):
self.assertEqual(len(responses), 0)
def test_one_plugin_active(self):
self.event.plugins = 'pretix.plugins.testdummy'
self.event.plugins = 'tests.testdummy'
self.event.save()
payload = {'foo': 'bar'}
responses = determine_availability.send(self.event, **payload)
self.assertEqual(len(responses), 1)
self.assertIn('pretix.plugins.testdummy.signals', [r[0].__module__ for r in responses])
self.assertIn('tests.testdummy.signals', [r[0].__module__ for r in responses])

View File

@@ -328,7 +328,7 @@ class CartTest(CartTestMixin, TestCase):
self.assertFalse(CartPosition.objects.current.filter(user=self.user, event=self.event).exists())
def test_restriction_failed(self):
self.event.plugins = 'pretix.plugins.testdummy'
self.event.plugins = 'tests.testdummy'
self.event.save()
self.event.settings.testdummy_available = 'yes'
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
@@ -343,7 +343,7 @@ class CartTest(CartTestMixin, TestCase):
self.assertEqual(objs[0].price, 23)
def test_restriction_ok(self):
self.event.plugins = 'pretix.plugins.testdummy'
self.event.plugins = 'tests.testdummy'
self.event.save()
self.event.settings.testdummy_available = 'no'
response = self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {

View File

@@ -3,3 +3,7 @@ from pretix.settings import *
TEST_DIR = os.path.dirname(__file__)
TEMPLATES[0]['DIRS'].append(os.path.join(TEST_DIR, 'templates'))
INSTALLED_APPS = INSTALLED_APPS + (
'tests.testdummy',
)

View File

@@ -0,0 +1,18 @@
from django.apps import AppConfig
from pretix.base.plugins import PluginType
class TestDummyApp(AppConfig):
name = 'tests.testdummy'
verbose_name = '.testdummy'
class PretixPluginMeta:
type = PluginType.RESTRICTION
name = '.testdummy'
version = '1.0.0'
def ready(self):
from tests.testdummy import signals
default_app_config = 'tests.testdummy.TestDummyApp'

View File

View File

@@ -0,0 +1,15 @@
from django.dispatch import receiver
from pretix.base.signals import determine_availability
@receiver(determine_availability)
def availability_handler(sender, **kwargs):
kwargs['sender'] = sender
if sender.settings.testdummy_available is not None:
variations = kwargs['variations']
variations = [d.copy() for d in variations]
for v in variations:
v['available'] = (sender.settings.testdummy_available == 'yes')
return variations
return []