tests: check for meetings with different durations

This commit is contained in:
Frédéric Péters 2017-02-21 17:54:08 +01:00
parent 34615709cf
commit de7e84dc5b
1 changed files with 54 additions and 0 deletions

View File

@ -208,6 +208,60 @@ def test_booking_api_meeting(app, meetings_agenda, user):
assert resp.json['err'] == 1
assert resp.json['reason'] == 'sold out'
def test_booking_api_meeting_different_durations_book_short(app, meetings_agenda, user):
agenda_id = meetings_agenda.id
meeting_type = MeetingType.objects.get(agenda=meetings_agenda)
meeting_type_2 = MeetingType(agenda=meetings_agenda, label='Shorter', duration=15)
meeting_type_2.save()
# get long events
resp_long = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type.id)
# book a short event
resp = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type_2.id)
event_id = resp.json['data'][0]['id']
app.authorization = ('Basic', ('john.doe', 'password'))
app.post('/api/agenda/%s/fillslot/%s/' % (agenda_id, event_id))
assert Booking.objects.count() == 1
# the longer event at the same time shouldn't be available anymore
resp_long2 = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type.id)
assert len(resp_long.json['data']) == len(resp_long2.json['data']) + 1
assert resp_long.json['data'][1:] == resp_long2.json['data']
def test_booking_api_meeting_different_durations_book_long(app, meetings_agenda, user):
agenda_id = meetings_agenda.id
meeting_type = MeetingType.objects.get(agenda=meetings_agenda)
meeting_type_2 = MeetingType(agenda=meetings_agenda, label='Shorter', duration=15)
meeting_type_2.save()
# get short events
resp_short = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type_2.id)
# book a long event
resp = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type.id)
event_id = resp.json['data'][0]['id']
app.authorization = ('Basic', ('john.doe', 'password'))
app.post('/api/agenda/%s/fillslot/%s/' % (agenda_id, event_id))
assert Booking.objects.count() == 1
# this should have removed two short events
resp_short2 = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type_2.id)
assert len(resp_short.json['data']) == len(resp_short2.json['data']) + 2
# book another long event
event_id = resp.json['data'][10]['id']
app.authorization = ('Basic', ('john.doe', 'password'))
app.post('/api/agenda/%s/fillslot/%s/' % (agenda_id, event_id))
assert Booking.objects.count() == 2
resp_short2 = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type_2.id)
assert len(resp_short.json['data']) == len(resp_short2.json['data']) + 4
def test_booking_api_with_data(app, some_data, user):
agenda_id = Agenda.objects.filter(label=u'Foo bar')[0].id
event = Event.objects.filter(agenda_id=agenda_id)[0]