This commit is contained in:
parent
c35dffb1bb
commit
d33be64bff
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
import random
|
||||
import urllib.parse as urlparse
|
||||
from unittest import mock
|
||||
|
||||
|
@ -1065,23 +1066,28 @@ def test_booking_api_meeting_date_time_period(app, user):
|
|||
|
||||
def test_booking_api_available(app, user):
|
||||
agenda = Agenda.objects.create(label='Foo bar', kind='events', minimal_booking_delay=0)
|
||||
events = []
|
||||
for i in range(0, 10):
|
||||
event = Event.objects.create(
|
||||
slug='event-slug%i' % i,
|
||||
start_datetime=(now() + datetime.timedelta(days=5)).replace(hour=10, minute=i),
|
||||
places=20,
|
||||
agenda=agenda,
|
||||
events.append(
|
||||
Event.objects.create(
|
||||
slug='event-slug%i' % i,
|
||||
start_datetime=(now() + datetime.timedelta(days=5)).replace(hour=10, minute=i),
|
||||
places=20,
|
||||
agenda=agenda,
|
||||
)
|
||||
)
|
||||
event = random.choice(events)
|
||||
app.authorization = ('Basic', ('john.doe', 'password'))
|
||||
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug)
|
||||
assert len(ctx.captured_queries) == 3
|
||||
assert resp.json['data'][-1]['places']['total'] == 20
|
||||
assert resp.json['data'][-1]['places']['available'] == 20
|
||||
assert resp.json['data'][-1]['places']['reserved'] == 0
|
||||
assert resp.json['data'][-1]['places']['full'] is False
|
||||
assert 'waiting_list_total' not in resp.json['data'][-1]['places']
|
||||
event_data = [d for d in resp.json['data'] if d['id'] == event.slug][0]
|
||||
assert event_data['places']['total'] == 20
|
||||
assert event_data['places']['available'] == 20
|
||||
assert event_data['places']['reserved'] == 0
|
||||
assert event_data['places']['full'] is False
|
||||
assert 'waiting_list_total' not in event_data['places']
|
||||
|
||||
resp = app.post_json('/api/agenda/%s/fillslot/%s/' % (agenda.pk, event.pk))
|
||||
assert resp.json['err'] == 0
|
||||
|
@ -1092,11 +1098,12 @@ def test_booking_api_available(app, user):
|
|||
assert 'waiting_list_total' not in resp.json['places']
|
||||
|
||||
resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug)
|
||||
assert resp.json['data'][-1]['places']['total'] == 20
|
||||
assert resp.json['data'][-1]['places']['available'] == 19
|
||||
assert resp.json['data'][-1]['places']['reserved'] == 1
|
||||
assert resp.json['data'][-1]['places']['full'] is False
|
||||
assert 'waiting_list_total' not in resp.json['data'][-1]['places']
|
||||
event_data = [d for d in resp.json['data'] if d['id'] == event.slug][0]
|
||||
assert event_data['places']['total'] == 20
|
||||
assert event_data['places']['available'] == 19
|
||||
assert event_data['places']['reserved'] == 1
|
||||
assert event_data['places']['full'] is False
|
||||
assert 'waiting_list_total' not in event_data['places']
|
||||
|
||||
Booking.objects.create(event=event, in_waiting_list=True)
|
||||
event.waiting_list_places = 5
|
||||
|
@ -1114,14 +1121,15 @@ def test_booking_api_available(app, user):
|
|||
assert resp.json['places']['waiting_list_activated'] is True
|
||||
|
||||
resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug)
|
||||
assert resp.json['data'][-1]['places']['total'] == 20
|
||||
assert resp.json['data'][-1]['places']['available'] == 19
|
||||
assert resp.json['data'][-1]['places']['reserved'] == 1
|
||||
assert resp.json['data'][-1]['places']['full'] is False
|
||||
assert resp.json['data'][-1]['places']['waiting_list_total'] == 5
|
||||
assert resp.json['data'][-1]['places']['waiting_list_available'] == 3
|
||||
assert resp.json['data'][-1]['places']['waiting_list_reserved'] == 2
|
||||
assert resp.json['data'][-1]['places']['waiting_list_activated'] is True
|
||||
event_data = [d for d in resp.json['data'] if d['id'] == event.slug][0]
|
||||
assert event_data['places']['total'] == 20
|
||||
assert event_data['places']['available'] == 19
|
||||
assert event_data['places']['reserved'] == 1
|
||||
assert event_data['places']['full'] is False
|
||||
assert event_data['places']['waiting_list_total'] == 5
|
||||
assert event_data['places']['waiting_list_available'] == 3
|
||||
assert event_data['places']['waiting_list_reserved'] == 2
|
||||
assert event_data['places']['waiting_list_activated'] is True
|
||||
|
||||
# not for mettings agenda
|
||||
meetings_agenda = Agenda.objects.create(label='meetings', kind='meetings')
|
||||
|
|
Loading…
Reference in New Issue