forked from CGM_Public/pretix_original
* MKBDIGI-183: Added quotas API write methods * MKBDIGI-183: Fixed code formatting * MKBDIGI-183: Added test for permission requirements * MKBDIGI-183: Documentation corrections * MKBDIGI-183: Removed redundant create/update locks * MKBDIGI-183: Added quota validation to check that items and variations corresponds to each other * MKBDIGI-183: Added quota validation to check that item belong to the same event as the endpoint * MKBDIGI-183: Added subevent validation to check that subevent belong to the same event as the endpoint * MKBDIGI-183: Added subevent validation to check that subevent is null for non-series events * MKBDIGI-183: Changed validation error text * MKBDIGI-183: Added logging for subevents * MKBDIGI-183: Fixed code formatting * MKBDIGI-183: Fixed validation error in API test * MKBDIGI-183: Fixed documentation errors * MKBDIGI-183: Fixed typos in validation messages * MKBDIGI-183: Refactored validation loop vars check * MKBDIGI-183: Updated error strings in test assersions * MKBDIGI-183: Fixed logging for API quota update to account changing subevents
109 lines
2.8 KiB
Python
109 lines
2.8 KiB
Python
from datetime import datetime
|
|
|
|
import pytest
|
|
from pytz import UTC
|
|
from rest_framework.test import APIClient
|
|
|
|
from pretix.base.models import Event, Organizer, Team, User
|
|
|
|
|
|
@pytest.fixture
|
|
def client():
|
|
return APIClient()
|
|
|
|
|
|
@pytest.fixture
|
|
def organizer():
|
|
return Organizer.objects.create(name='Dummy', slug='dummy')
|
|
|
|
|
|
@pytest.fixture
|
|
def meta_prop(organizer):
|
|
return organizer.meta_properties.create(name="type", default="Concert")
|
|
|
|
|
|
@pytest.fixture
|
|
def event(organizer, meta_prop):
|
|
e = Event.objects.create(
|
|
organizer=organizer, name='Dummy', slug='dummy',
|
|
date_from=datetime(2017, 12, 27, 10, 0, 0, tzinfo=UTC),
|
|
plugins='pretix.plugins.banktransfer,pretix.plugins.ticketoutputpdf'
|
|
)
|
|
e.meta_values.create(property=meta_prop, value="Conference")
|
|
return e
|
|
|
|
|
|
@pytest.fixture
|
|
def event2(organizer, meta_prop):
|
|
e = Event.objects.create(
|
|
organizer=organizer, name='Dummy2', slug='dummy2',
|
|
date_from=datetime(2017, 12, 27, 10, 0, 0, tzinfo=UTC),
|
|
plugins='pretix.plugins.banktransfer,pretix.plugins.ticketoutputpdf'
|
|
)
|
|
e.meta_values.create(property=meta_prop, value="Conference")
|
|
return e
|
|
|
|
|
|
@pytest.fixture
|
|
def event3(organizer, meta_prop):
|
|
e = Event.objects.create(
|
|
organizer=organizer, name='Dummy3', slug='dummy3',
|
|
date_from=datetime(2017, 12, 27, 10, 0, 0, tzinfo=UTC),
|
|
plugins='pretix.plugins.banktransfer,pretix.plugins.ticketoutputpdf'
|
|
)
|
|
e.meta_values.create(property=meta_prop, value="Conference")
|
|
return e
|
|
|
|
|
|
@pytest.fixture
|
|
def team(organizer):
|
|
return Team.objects.create(
|
|
organizer=organizer,
|
|
can_change_items=True,
|
|
can_change_event_settings=True,
|
|
can_change_vouchers=True,
|
|
can_view_vouchers=True,
|
|
can_change_orders=True,
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def user():
|
|
return User.objects.create_user('dummy@dummy.dummy', 'dummy')
|
|
|
|
|
|
@pytest.fixture
|
|
def token_client(client, team):
|
|
team.can_view_orders = True
|
|
team.can_view_vouchers = True
|
|
team.all_events = True
|
|
team.save()
|
|
t = team.tokens.create(name='Foo')
|
|
client.credentials(HTTP_AUTHORIZATION='Token ' + t.token)
|
|
return client
|
|
|
|
|
|
@pytest.fixture
|
|
def subevent(event, meta_prop):
|
|
event.has_subevents = True
|
|
event.save()
|
|
se = event.subevents.create(name="Foobar", date_from=datetime(2017, 12, 27, 10, 0, 0, tzinfo=UTC))
|
|
|
|
se.meta_values.create(property=meta_prop, value="Workshop")
|
|
return se
|
|
|
|
|
|
@pytest.fixture
|
|
def subevent2(event2, meta_prop):
|
|
event2.has_subevents = True
|
|
event2.save()
|
|
se = event2.subevents.create(name="Foobar", date_from=datetime(2017, 12, 27, 10, 0, 0, tzinfo=UTC))
|
|
|
|
se.meta_values.create(property=meta_prop, value="Workshop")
|
|
return se
|
|
|
|
|
|
@pytest.fixture
|
|
def taxrule(event):
|
|
return event.tax_rules.create(name="VAT", rate=19)
|