mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Display a timeline on the dashboard (#1290)
* Timeline data model * Display timeline * … * More events * Plugin support * Fix docs typo
This commit is contained in:
50
src/tests/base/test_timeline.py
Normal file
50
src/tests/base/test_timeline.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
import pytz
|
||||
|
||||
from pretix.base.models import Event, Organizer
|
||||
from pretix.base.timeline import timeline_for_event
|
||||
|
||||
tz = pytz.timezone('Europe/Berlin')
|
||||
|
||||
|
||||
def one(iterable):
|
||||
found = False
|
||||
for it in iterable:
|
||||
if it:
|
||||
if found:
|
||||
return False
|
||||
else:
|
||||
found = True
|
||||
return found
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def event():
|
||||
o = Organizer.objects.create(name='Dummy', slug='dummy')
|
||||
event = Event.objects.create(
|
||||
organizer=o, name='Dummy', slug='dummy',
|
||||
date_from=datetime(2017, 10, 22, 12, 0, 0, tzinfo=tz),
|
||||
date_to=datetime(2017, 10, 23, 23, 0, 0, tzinfo=tz),
|
||||
)
|
||||
return event
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def item(event):
|
||||
return event.items.create(name='Ticket', default_price=Decimal('23.00'))
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_event_dates(event):
|
||||
tl = timeline_for_event(event)
|
||||
assert one([
|
||||
e for e in tl
|
||||
if e.event == event and e.datetime == event.date_from and e.description == 'Your event starts'
|
||||
])
|
||||
assert one([
|
||||
e for e in tl
|
||||
if e.event == event and e.datetime == event.date_to and e.description == 'Your event ends'
|
||||
])
|
||||
Reference in New Issue
Block a user