Skip to content

Commit

Permalink
Adds testcase to reproduce pretix#24
Browse files Browse the repository at this point in the history
  • Loading branch information
bockstaller committed Nov 10, 2021
1 parent 1538712 commit 170ca93
Showing 1 changed file with 48 additions and 5 deletions.
53 changes: 48 additions & 5 deletions pretix_sepadebit/tests/test_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,29 @@
Event, Item, Order, OrderPayment, Organizer, Quota,
)

from pretix_sepadebit.models import SepaDueDate
from pretix_sepadebit.models import SepaDueDate, SepaExport, SepaExportOrder
from pretix_sepadebit.payment import SepaDebit
from pretix_sepadebit.signals import send_payment_reminders
from pretix_sepadebit.views import EventExportListView, OrganizerExportListView

migration = importlib.import_module('pretix_sepadebit.migrations.0007_sepaduedate')
@pytest.fixture
def organizer():
o = Organizer.objects.create(name="Dummy", slug="dummy")
o.save()
return o


@pytest.fixture
def event():
def event(organizer):
# IBAN and BIC are random values
o = Organizer.objects.create(name='Dummy', slug='dummy')

event = Event.objects.create(
organizer=o, name='Dummy', slug='dummy',
date_from=now(), plugins='pretix.plugins.sepadebit'
organizer=organizer,
name="Dummy",
slug="dummy",
date_from=now(),
plugins="pretix.plugins.sepadebit",
)
event.settings.set('payment_sepadebit_creditor_name', '1.00')
event.settings.set('payment_sepadebit_creditor_iban', 'DE13495179316396679327')
Expand Down Expand Up @@ -56,6 +65,40 @@ def order(event):
return o


@pytest.mark.django_db
def test_unexported_not_refundable(event, order):
with scopes_disabled():
ts = now()

payment = orderpayment(
order, date=ts, remind_after=ts, reminded=False, old_format=False
)
payment.save()

provider = SepaDebit(event)
assert provider.payment_refund_supported(payment) == True


@pytest.mark.django_db
def test_exported_refundable(organizer, event, order):
with scopes_disabled():
ts = now()

payment = orderpayment(
order, date=ts, remind_after=ts, reminded=False, old_format=False
)
payment.save()

export = SepaExport(event=event, organizer=organizer)
export.save()
order_export = SepaExportOrder(
export=export, order=order, payment=payment, amount=10
)
order_export.save()

provider = SepaDebit(event)
assert provider.payment_refund_supported(payment) == True


def orderpayment(order, date, remind_after, reminded=None, old_format=True):
op_date = date
Expand Down

0 comments on commit 170ca93

Please sign in to comment.