mirror of
https://github.com/pretix/pretix.git
synced 2026-09-12 16:04:42 +00:00
Merge branch 'master' into self-service-storno
This commit is contained in:
@@ -2479,6 +2479,7 @@ TEST_QUESTION_RES = {
|
||||
"valid_datetime_min": None,
|
||||
"valid_datetime_max": None,
|
||||
"valid_file_portrait": False,
|
||||
"valid_string_length_min": None,
|
||||
"valid_string_length_max": None,
|
||||
"help_text": {"en": "This is an example question"},
|
||||
"options": [
|
||||
|
||||
@@ -61,17 +61,21 @@ def test_rule_detail(token_client, organizer, event, taxrule):
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_rule_create(token_client, organizer, event):
|
||||
resp = token_client.post(
|
||||
'/api/v1/organizers/{}/events/{}/taxrules/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
"name": {"en": "VAT", "de": "MwSt"},
|
||||
"rate": "19.00",
|
||||
"price_includes_tax": True,
|
||||
"eu_reverse_charge": False,
|
||||
"home_country": "DE"
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
url = '/api/v1/organizers/{}/events/{}/taxrules/'.format(organizer.slug, event.slug)
|
||||
payload = {
|
||||
"name": {"en": "VAT", "de": "MwSt"},
|
||||
"rate": "19.00",
|
||||
"price_includes_tax": True,
|
||||
"eu_reverse_charge": False,
|
||||
"home_country": "DE",
|
||||
"default": False,
|
||||
}
|
||||
# fail as only one rule exists and must be default
|
||||
resp = token_client.post(url, payload, format='json')
|
||||
assert resp.status_code == 400
|
||||
|
||||
del payload["default"]
|
||||
resp = token_client.post(url, payload, format='json')
|
||||
assert resp.status_code == 201
|
||||
rule = TaxRule.objects.get(pk=resp.data['id'])
|
||||
assert rule.name.data == {"en": "VAT", "de": "MwSt"}
|
||||
@@ -79,6 +83,7 @@ def test_rule_create(token_client, organizer, event):
|
||||
assert rule.price_includes_tax is True
|
||||
assert rule.eu_reverse_charge is False
|
||||
assert str(rule.home_country) == "DE"
|
||||
assert rule.default is True
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
||||
@@ -83,6 +83,7 @@ def test_team_detail(token_client, organizer, event, second_team):
|
||||
TEST_TEAM_CREATE_PAYLOAD = {
|
||||
"name": "Foobar",
|
||||
"limit_events": ["dummy"],
|
||||
"can_view_orders": True,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2970,8 +2970,9 @@ class SeatingTestCase(TestCase):
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize("qtype,answer,expected", [
|
||||
(Question.TYPE_STRING, "a", "a"),
|
||||
(Question.TYPE_TEXT, "v", "v"),
|
||||
(Question.TYPE_STRING, "aaa", "aaa"),
|
||||
(Question.TYPE_STRING, "a", ValidationError),
|
||||
(Question.TYPE_TEXT, "vvv", "vvv"),
|
||||
(Question.TYPE_TEXT, "waaaaay tooooo long", ValidationError),
|
||||
(Question.TYPE_NUMBER, "0.9", ValidationError),
|
||||
(Question.TYPE_NUMBER, "1", Decimal("1")),
|
||||
@@ -3025,6 +3026,7 @@ def test_question_answer_validation(qtype, answer, expected):
|
||||
valid_datetime_max=datetime.datetime(2018, 1, 16, 16, 0, 0, tzinfo=tzoffset(None, 3600)),
|
||||
valid_number_min=Decimal('1'),
|
||||
valid_number_max=Decimal('100'),
|
||||
valid_string_length_min=3,
|
||||
valid_string_length_max=8,
|
||||
)
|
||||
if isinstance(expected, type) and issubclass(expected, Exception):
|
||||
|
||||
@@ -286,6 +286,30 @@ def test_expiry_dst(event):
|
||||
assert (localex.hour, localex.minute) == (23, 59)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_expiry_per_channel(event):
|
||||
today = now()
|
||||
event.settings.set('payment_term_mode', 'minutes')
|
||||
event.settings.set('payment_term_minutes', 30)
|
||||
event.settings.set('payment_term_mode_baz', 'minutes')
|
||||
event.settings.set('payment_term_minutes_baz', 15)
|
||||
order = _create_order(event, email='dummy@example.org', positions=[],
|
||||
now_dt=today,
|
||||
sales_channel=event.organizer.sales_channels.get(identifier="baz"),
|
||||
payment_requests=[{
|
||||
"id": "test0",
|
||||
"provider": "free",
|
||||
"max_value": None,
|
||||
"min_value": None,
|
||||
"multi_use_supported": False,
|
||||
"info_data": {},
|
||||
"pprov": FreeOrderProvider(event),
|
||||
}],
|
||||
locale='de')[0]
|
||||
assert (order.expires - today).days == 0
|
||||
assert (order.expires - today).seconds == 15 * 60
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_expiring(event):
|
||||
o1 = Order.objects.create(
|
||||
|
||||
@@ -37,18 +37,20 @@ import re
|
||||
from decimal import Decimal
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from django.core import mail as djmail
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.test import TestCase
|
||||
from django.utils.timezone import now
|
||||
from django_scopes import scopes_disabled
|
||||
|
||||
from pretix.base.models import (
|
||||
Event, Item, ItemCategory, ItemVariation, Order, OrderPosition, Organizer,
|
||||
Question, Quota,
|
||||
Event, Invoice, InvoiceAddress, Item, ItemCategory, ItemVariation, Order,
|
||||
OrderPosition, Organizer, Question, Quota,
|
||||
)
|
||||
from pretix.base.models.orders import OrderFee, OrderPayment
|
||||
from pretix.base.reldate import RelativeDate, RelativeDateWrapper
|
||||
from pretix.base.services.invoices import generate_invoice
|
||||
from pretix.testutils.scope import classscope
|
||||
|
||||
|
||||
class BaseOrdersTest(TestCase):
|
||||
@@ -1702,6 +1704,63 @@ class OrdersTest(BaseOrdersTest):
|
||||
assert 'Gift card' in response.content.decode()
|
||||
assert '1 available' in response.content.decode()
|
||||
|
||||
@classscope("orga")
|
||||
def test_change_paymentmethod_invoice(self):
|
||||
self.event.settings.payment_banktransfer__enabled = True
|
||||
self.event.settings.payment_banktransfer_invoice_immediately = True
|
||||
self.event.settings.invoice_generate = "paid"
|
||||
InvoiceAddress.objects.create(
|
||||
order=self.order,
|
||||
transmission_type="email"
|
||||
)
|
||||
|
||||
assert self.order.invoices.count() == 0
|
||||
|
||||
with self.captureOnCommitCallbacks(execute=True):
|
||||
self.client.post(
|
||||
'/%s/%s/order/%s/%s/pay/change' % (self.orga.slug, self.event.slug, self.order.code, self.order.secret),
|
||||
{
|
||||
'payment': 'banktransfer'
|
||||
}
|
||||
)
|
||||
|
||||
assert self.order.payments.last().provider == 'banktransfer'
|
||||
assert self.order.invoices.count() == 1
|
||||
i = self.order.invoices.last()
|
||||
assert i.transmission_status == Invoice.TRANSMISSION_STATUS_PENDING
|
||||
assert len(djmail.outbox) == 0
|
||||
|
||||
@classscope("orga")
|
||||
def test_change_paymentmethod_invoice_separately(self):
|
||||
self.event.settings.payment_banktransfer__enabled = True
|
||||
self.event.settings.payment_banktransfer_invoice_immediately = True
|
||||
self.event.settings.invoice_generate = "paid"
|
||||
InvoiceAddress.objects.create(
|
||||
order=self.order,
|
||||
transmission_type="email",
|
||||
transmission_info={
|
||||
"transmission_email_other": True,
|
||||
"transmission_email_address": "invoice@example.org",
|
||||
}
|
||||
)
|
||||
|
||||
assert self.order.invoices.count() == 0
|
||||
|
||||
with self.captureOnCommitCallbacks(execute=True):
|
||||
self.client.post(
|
||||
'/%s/%s/order/%s/%s/pay/change' % (self.orga.slug, self.event.slug, self.order.code, self.order.secret),
|
||||
{
|
||||
'payment': 'banktransfer'
|
||||
}
|
||||
)
|
||||
|
||||
assert self.order.payments.last().provider == 'banktransfer'
|
||||
assert self.order.invoices.count() == 1
|
||||
i = self.order.invoices.last()
|
||||
assert i.transmission_status == Invoice.TRANSMISSION_STATUS_COMPLETED
|
||||
assert ["invoice@example.org"] == djmail.outbox[0].to
|
||||
assert any(["Invoice_" in a[0] for a in djmail.outbox[0].attachments])
|
||||
|
||||
def test_answer_download_token(self):
|
||||
with scopes_disabled():
|
||||
q = self.event.questions.create(question="Foo", type="F")
|
||||
|
||||
Reference in New Issue
Block a user