forked from CGM_Public/pretix_original
API: Allow to simulate orders
This commit is contained in:
@@ -19,7 +19,7 @@ from pretix.base.models import (
|
||||
InvoiceAddress, Order, OrderPosition, Question, SeatingPlan,
|
||||
)
|
||||
from pretix.base.models.orders import (
|
||||
CartPosition, OrderFee, OrderPayment, OrderRefund,
|
||||
CartPosition, OrderFee, OrderPayment, OrderRefund, QuestionAnswer,
|
||||
)
|
||||
from pretix.base.services.invoices import (
|
||||
generate_cancellation, generate_invoice,
|
||||
@@ -1539,6 +1539,111 @@ def test_order_create(token_client, organizer, event, item, quota, question):
|
||||
assert answ.answer == "S"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_order_create_simulate(token_client, organizer, event, item, quota, question):
|
||||
res = copy.deepcopy(ORDER_CREATE_PAYLOAD)
|
||||
question.type = Question.TYPE_CHOICE_MULTIPLE
|
||||
question.save()
|
||||
with scopes_disabled():
|
||||
opt = question.options.create(answer="L")
|
||||
res['positions'][0]['item'] = item.pk
|
||||
res['positions'][0]['answers'][0]['question'] = question.pk
|
||||
res['positions'][0]['answers'][0]['options'] = [opt.pk]
|
||||
res['simulate'] = True
|
||||
resp = token_client.post(
|
||||
'/api/v1/organizers/{}/events/{}/orders/'.format(
|
||||
organizer.slug, event.slug
|
||||
), format='json', data=res
|
||||
)
|
||||
assert resp.status_code == 201
|
||||
with scopes_disabled():
|
||||
assert Order.objects.count() == 0
|
||||
assert QuestionAnswer.objects.count() == 0
|
||||
assert OrderPosition.objects.count() == 0
|
||||
assert OrderFee.objects.count() == 0
|
||||
assert InvoiceAddress.objects.count() == 0
|
||||
d = resp.data
|
||||
del d['last_modified']
|
||||
del d['secret']
|
||||
del d['url']
|
||||
del d['expires']
|
||||
del d['invoice_address']['last_modified']
|
||||
del d['positions'][0]['secret']
|
||||
assert d == {
|
||||
'code': 'PREVIEW',
|
||||
'status': 'n',
|
||||
'testmode': False,
|
||||
'email': 'dummy@dummy.test',
|
||||
'locale': 'en',
|
||||
'datetime': None,
|
||||
'payment_date': None,
|
||||
'payment_provider': None,
|
||||
'fees': [
|
||||
{
|
||||
'fee_type': 'payment',
|
||||
'value': '0.25',
|
||||
'description': '',
|
||||
'internal_type': '',
|
||||
'tax_rate': '0.00',
|
||||
'tax_value': '0.00',
|
||||
'tax_rule': None,
|
||||
'canceled': False
|
||||
}
|
||||
],
|
||||
'total': '23.25',
|
||||
'comment': '',
|
||||
'invoice_address': {
|
||||
'is_business': False,
|
||||
'company': 'Sample company',
|
||||
'name': 'Fo',
|
||||
'name_parts': {'full_name': 'Fo', '_scheme': 'full'},
|
||||
'street': 'Bar',
|
||||
'zipcode': '',
|
||||
'city': 'Sample City',
|
||||
'country': 'NZ',
|
||||
'state': '',
|
||||
'vat_id': '',
|
||||
'vat_id_validated': False,
|
||||
'internal_reference': ''
|
||||
},
|
||||
'positions': [
|
||||
{
|
||||
'id': 0,
|
||||
'order': '',
|
||||
'positionid': 1,
|
||||
'item': 1,
|
||||
'variation': None,
|
||||
'price': '23.00',
|
||||
'attendee_name': 'Peter',
|
||||
'attendee_name_parts': {'full_name': 'Peter', '_scheme': 'full'},
|
||||
'attendee_email': None,
|
||||
'voucher': None,
|
||||
'tax_rate': '0.00',
|
||||
'tax_value': '0.00',
|
||||
'addon_to': None,
|
||||
'subevent': None,
|
||||
'checkins': [],
|
||||
'downloads': [],
|
||||
'answers': [
|
||||
{'question': question.pk, 'answer': 'L', 'question_identifier': 'ABC',
|
||||
'options': [opt.pk],
|
||||
'option_identifiers': [opt.identifier]}
|
||||
],
|
||||
'tax_rule': None,
|
||||
'pseudonymization_id': 'PREVIEW',
|
||||
'seat': None,
|
||||
'canceled': False
|
||||
}
|
||||
],
|
||||
'downloads': [],
|
||||
'checkin_attention': False,
|
||||
'payments': [],
|
||||
'refunds': [],
|
||||
'require_approval': False,
|
||||
'sales_channel': 'web',
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_order_create_autocheckin(token_client, organizer, event, item, quota, question, clist_autocheckin):
|
||||
res = copy.deepcopy(ORDER_CREATE_PAYLOAD)
|
||||
|
||||
Reference in New Issue
Block a user