100 |
100 |
resp = app.get('/api/agenda/')
|
101 |
101 |
assert resp.json == {'data': [
|
102 |
102 |
{'text': 'Foo bar', 'id': u'foo-bar', 'slug': 'foo-bar', 'kind': 'events',
|
103 |
|
'api': {'datetimes_url': 'http://testserver/api/agenda/%s/datetimes/' % agenda1.slug}},
|
|
103 |
'api': {'datetimes_url': 'http://testserver/api/agenda/%s/datetimes/' % agenda1.slug,
|
|
104 |
'fillslots_url': 'http://testserver/api/agenda/%s/fillslots/' % agenda1.slug}},
|
104 |
105 |
{'text': 'Foo bar Meeting', 'id': u'foo-bar-meeting', 'slug': 'foo-bar-meeting',
|
105 |
106 |
'kind': 'meetings',
|
106 |
107 |
'api': {'meetings_url': 'http://testserver/api/agenda/%s/meetings/' % meetings_agenda.slug,
|
107 |
108 |
'desks_url': 'http://testserver/api/agenda/%s/desks/' % meetings_agenda.slug,
|
|
109 |
'fillslots_url': 'http://testserver/api/agenda/%s/fillslots/' % meetings_agenda.slug,
|
108 |
110 |
},
|
109 |
111 |
},
|
110 |
112 |
{'text': 'Foo bar2', 'id': u'foo-bar2', 'kind': 'events', 'slug': 'foo-bar2',
|
111 |
|
'api': {'datetimes_url': 'http://testserver/api/agenda/%s/datetimes/' % agenda2.slug}}
|
|
113 |
'api': {'datetimes_url': 'http://testserver/api/agenda/%s/datetimes/' % agenda2.slug,
|
|
114 |
'fillslots_url': 'http://testserver/api/agenda/%s/fillslots/' % agenda2.slug}}
|
112 |
115 |
]}
|
113 |
116 |
|
114 |
117 |
def test_agendas_meetingtypes_api(app, some_data, meetings_agenda):
|
... | ... | |
290 |
293 |
resp = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type.id)
|
291 |
294 |
assert len(resp.json['data']) == 2
|
292 |
295 |
fillslot_url = resp.json['data'][0]['api']['fillslot_url']
|
|
296 |
two_slots = [resp.json['data'][0]['id'], resp.json['data'][1]['id']]
|
293 |
297 |
|
294 |
298 |
time_period.end_time = datetime.time(10, 15)
|
295 |
299 |
time_period.save()
|
... | ... | |
301 |
305 |
resp = app.post(fillslot_url)
|
302 |
306 |
assert resp.json['err'] == 1
|
303 |
307 |
assert resp.json['reason'] == 'no more desk available'
|
|
308 |
# booking the two slots fails too
|
|
309 |
fillslots_url = '/api/agenda/%s/fillslots/' % meeting_type.agenda.slug
|
|
310 |
resp = app.post(fillslots_url, params={'slots': two_slots})
|
|
311 |
assert resp.json['err'] == 1
|
|
312 |
assert resp.json['reason'] == 'no more desk available'
|
304 |
313 |
|
305 |
314 |
def test_booking_api(app, some_data, user):
|
306 |
315 |
agenda = Agenda.objects.filter(label=u'Foo bar')[0]
|
... | ... | |
309 |
318 |
# unauthenticated
|
310 |
319 |
resp = app.post('/api/agenda/%s/fillslot/%s/' % (agenda.slug, event.id), status=403)
|
311 |
320 |
|
312 |
|
resp_datetimes = app.get('/api/agenda/%s/datetimes/' % agenda.id)
|
313 |
|
event_fillslot_url = [x for x in resp_datetimes.json['data'] if x['id'] == event.id][0]['api']['fillslot_url']
|
314 |
|
assert urlparse.urlparse(event_fillslot_url).path == '/api/agenda/%s/fillslot/%s/' % (agenda.slug, event.id)
|
|
321 |
for agenda_key in (agenda.slug, agenda.id): # acces datetimes via agenda slug or id (legacy)
|
|
322 |
resp_datetimes = app.get('/api/agenda/%s/datetimes/' % agenda_key)
|
|
323 |
event_fillslot_url = [x for x in resp_datetimes.json['data'] if x['id'] == event.id][0]['api']['fillslot_url']
|
|
324 |
assert urlparse.urlparse(event_fillslot_url).path == '/api/agenda/%s/fillslot/%s/' % (agenda.slug, event.id)
|
315 |
325 |
|
316 |
326 |
app.authorization = ('Basic', ('john.doe', 'password'))
|
317 |
327 |
resp = app.post('/api/agenda/%s/fillslot/%s/' % (agenda.slug, event.id))
|
... | ... | |
360 |
370 |
|
361 |
371 |
resp = app.post('/api/agenda/233/fillslot/%s/' % event.id, status=404)
|
362 |
372 |
|
|
373 |
def test_booking_api_fillslots(app, some_data, user):
|
|
374 |
agenda = Agenda.objects.filter(label=u'Foo bar')[0]
|
|
375 |
events_ids = [x.id for x in Event.objects.filter(agenda=agenda) if x.in_bookable_period()]
|
|
376 |
assert len(events_ids) == 3
|
|
377 |
event = [x for x in Event.objects.filter(agenda=agenda) if x.in_bookable_period()][0] # first event
|
|
378 |
|
|
379 |
# unauthenticated
|
|
380 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug, status=403)
|
|
381 |
|
|
382 |
for agenda_key in (agenda.slug, agenda.id): # acces datetimes via agenda slug or id (legacy)
|
|
383 |
resp_datetimes = app.get('/api/agenda/%s/datetimes/' % agenda_key)
|
|
384 |
api_event_ids = [x['id'] for x in resp_datetimes.json['data']]
|
|
385 |
assert api_event_ids == events_ids
|
|
386 |
|
|
387 |
assert Booking.objects.count() == 0
|
|
388 |
|
|
389 |
app.authorization = ('Basic', ('john.doe', 'password'))
|
|
390 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug, params={'slots': events_ids})
|
|
391 |
primary_booking_id = resp.json['booking_id']
|
|
392 |
Booking.objects.get(id=primary_booking_id)
|
|
393 |
assert resp.json['datetime'] == localtime(event.start_datetime).isoformat()
|
|
394 |
assert 'accept_url' not in resp.json['api']
|
|
395 |
assert 'cancel_url' in resp.json['api']
|
|
396 |
assert urlparse.urlparse(resp.json['api']['cancel_url']).netloc
|
|
397 |
assert Booking.objects.count() == 3
|
|
398 |
# these 3 bookings are related, the first is the primary one
|
|
399 |
bookings = Booking.objects.all().order_by('primary_booking')
|
|
400 |
assert bookings[0].primary_booking is None
|
|
401 |
assert bookings[1].primary_booking.id == bookings[0].id == primary_booking_id
|
|
402 |
assert bookings[2].primary_booking.id == bookings[0].id == primary_booking_id
|
|
403 |
|
|
404 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug, params={'slots': events_ids})
|
|
405 |
primary_booking_id_2 = resp.json['booking_id']
|
|
406 |
assert Booking.objects.count() == 6
|
|
407 |
assert Booking.objects.filter(event__agenda=agenda).count() == 6
|
|
408 |
# 6 = 2 primary + 2*2 secondary
|
|
409 |
assert Booking.objects.filter(event__agenda=agenda, primary_booking__isnull=True).count() == 2
|
|
410 |
assert Booking.objects.filter(event__agenda=agenda, primary_booking=primary_booking_id).count() == 2
|
|
411 |
assert Booking.objects.filter(event__agenda=agenda, primary_booking=primary_booking_id_2).count() == 2
|
|
412 |
|
|
413 |
# test with additional data
|
|
414 |
resp = app.post_json('/api/agenda/%s/fillslots/' % agenda.id,
|
|
415 |
params={'slots': events_ids,
|
|
416 |
'label': 'foo', 'user_name': 'bar', 'backoffice_url': 'http://example.net/'})
|
|
417 |
booking_id = resp.json['booking_id']
|
|
418 |
assert Booking.objects.get(id=booking_id).label == 'foo'
|
|
419 |
assert Booking.objects.get(id=booking_id).user_name == 'bar'
|
|
420 |
assert Booking.objects.get(id=booking_id).backoffice_url == 'http://example.net/'
|
|
421 |
assert Booking.objects.filter(primary_booking=booking_id, label='foo').count() == 2
|
|
422 |
# cancel
|
|
423 |
cancel_url = resp.json['api']['cancel_url']
|
|
424 |
assert Booking.objects.filter(cancellation_datetime__isnull=False).count() == 0
|
|
425 |
assert Booking.objects.get(id=booking_id).cancellation_datetime is None
|
|
426 |
resp_cancel = app.post(cancel_url)
|
|
427 |
assert resp_cancel.json['err'] == 0
|
|
428 |
assert Booking.objects.filter(cancellation_datetime__isnull=False).count() == 3
|
|
429 |
assert Booking.objects.get(id=booking_id).cancellation_datetime is not None
|
|
430 |
|
|
431 |
# extra data stored in extra_data field
|
|
432 |
resp = app.post_json('/api/agenda/%s/fillslots/' % agenda.id,
|
|
433 |
params={'slots': events_ids,
|
|
434 |
'label': 'l', 'user_name': 'u', 'backoffice_url': '', 'foo': 'bar'})
|
|
435 |
assert Booking.objects.get(id=resp.json['booking_id']).label == 'l'
|
|
436 |
assert Booking.objects.get(id=resp.json['booking_id']).user_name == 'u'
|
|
437 |
assert Booking.objects.get(id=resp.json['booking_id']).backoffice_url == ''
|
|
438 |
assert Booking.objects.get(id=resp.json['booking_id']).extra_data == {'foo': 'bar'}
|
|
439 |
for booking in Booking.objects.filter(primary_booking=resp.json['booking_id']):
|
|
440 |
assert booking.extra_data == {'foo': 'bar'}
|
|
441 |
|
|
442 |
# test invalid data are refused
|
|
443 |
resp = app.post_json('/api/agenda/%s/fillslots/' % agenda.id,
|
|
444 |
params={'slots': events_ids,
|
|
445 |
'user_name': {'foo': 'bar'}}, status=400)
|
|
446 |
assert resp.json['err'] == 1
|
|
447 |
assert resp.json['reason'] == 'invalid payload'
|
|
448 |
assert len(resp.json['errors']) == 1
|
|
449 |
assert 'user_name' in resp.json['errors']
|
|
450 |
|
|
451 |
# empty or missing slots
|
|
452 |
resp = app.post_json('/api/agenda/%s/fillslots/' % agenda.id, params={'slots': []}, status=400)
|
|
453 |
assert resp.json['err'] == 1
|
|
454 |
assert resp.json['reason'] == 'slots list cannot be empty'
|
|
455 |
resp = app.post_json('/api/agenda/%s/fillslots/' % agenda.id, status=400)
|
|
456 |
assert resp.json['err'] == 1
|
|
457 |
assert resp.json['reason'] == 'slots list cannot be empty'
|
|
458 |
# invalid slots format
|
|
459 |
resp = app.post_json('/api/agenda/%s/fillslots/' % agenda.id, params={'slots': 'foobar'}, status=400)
|
|
460 |
assert resp.json['err'] == 1
|
|
461 |
assert resp.json['reason'] == 'invalid payload'
|
|
462 |
assert len(resp.json['errors']) == 1
|
|
463 |
assert 'slots' in resp.json['errors']
|
|
464 |
|
|
465 |
# unknown agendas
|
|
466 |
resp = app.post('/api/agenda/foobar/fillslots/', status=404)
|
|
467 |
resp = app.post('/api/agenda/233/fillslots/', status=404)
|
|
468 |
|
363 |
469 |
def test_booking_api_meeting(app, meetings_agenda, user):
|
364 |
470 |
agenda_id = meetings_agenda.slug
|
365 |
471 |
meeting_type = MeetingType.objects.get(agenda=meetings_agenda)
|
... | ... | |
390 |
496 |
assert resp.json['err'] == 0
|
391 |
497 |
assert Booking.objects.count() == 2
|
392 |
498 |
|
|
499 |
def test_booking_api_meeting_fillslots(app, meetings_agenda, user):
|
|
500 |
agenda_id = meetings_agenda.slug
|
|
501 |
meeting_type = MeetingType.objects.get(agenda=meetings_agenda)
|
|
502 |
resp = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type.id)
|
|
503 |
slots = [resp.json['data'][0]['id'], resp.json['data'][1]['id']]
|
|
504 |
|
|
505 |
app.authorization = ('Basic', ('john.doe', 'password'))
|
|
506 |
resp_booking = app.post('/api/agenda/%s/fillslots/' % agenda_id, params={'slots': slots})
|
|
507 |
assert Booking.objects.count() == 2
|
|
508 |
primary_booking = Booking.objects.filter(primary_booking__isnull=True).first()
|
|
509 |
secondary_booking = Booking.objects.filter(primary_booking=primary_booking.id).first()
|
|
510 |
assert resp_booking.json['datetime'][:16] == localtime(primary_booking.event.start_datetime
|
|
511 |
).isoformat()[:16]
|
|
512 |
assert resp_booking.json['end_datetime'][:16] == localtime(secondary_booking.event.end_datetime
|
|
513 |
).isoformat()[:16]
|
|
514 |
|
|
515 |
resp2 = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type.id)
|
|
516 |
assert len(resp.json['data']) == len([x for x in resp2.json['data'] if not x.get('disabled')]) + 2
|
|
517 |
|
|
518 |
# try booking the same timeslots
|
|
519 |
resp2 = app.post('/api/agenda/%s/fillslots/' % agenda_id, params={'slots': slots})
|
|
520 |
assert resp2.json['err'] == 1
|
|
521 |
assert resp2.json['reason'] == 'no more desk available'
|
|
522 |
|
|
523 |
# try booking partially free timeslots (one free, one busy)
|
|
524 |
nonfree_slots = [resp.json['data'][0]['id'], resp.json['data'][2]['id']]
|
|
525 |
resp2 = app.post('/api/agenda/%s/fillslots/' % agenda_id, params={'slots': nonfree_slots})
|
|
526 |
assert resp2.json['err'] == 1
|
|
527 |
assert resp2.json['reason'] == 'no more desk available'
|
|
528 |
|
|
529 |
# booking other free timeslots
|
|
530 |
free_slots = [resp.json['data'][3]['id'], resp.json['data'][2]['id']]
|
|
531 |
resp2 = app.post('/api/agenda/%s/fillslots/' % agenda_id, params={'slots': free_slots})
|
|
532 |
assert resp2.json['err'] == 0
|
|
533 |
cancel_url = resp2.json['api']['cancel_url']
|
|
534 |
assert Booking.objects.count() == 4
|
|
535 |
# 4 = 2 primary + 2 secondary
|
|
536 |
assert Booking.objects.filter(primary_booking__isnull=True).count() == 2
|
|
537 |
assert Booking.objects.filter(primary_booking__isnull=False).count() == 2
|
|
538 |
# cancel
|
|
539 |
assert Booking.objects.filter(cancellation_datetime__isnull=False).count() == 0
|
|
540 |
resp_cancel = app.post(cancel_url)
|
|
541 |
assert resp_cancel.json['err'] == 0
|
|
542 |
assert Booking.objects.filter(cancellation_datetime__isnull=False).count() == 2
|
|
543 |
|
|
544 |
impossible_slots = ['1:2017-05-22-1130', '2:2017-05-22-1100']
|
|
545 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda_id,
|
|
546 |
params={'slots': impossible_slots},
|
|
547 |
status=400)
|
|
548 |
assert resp.json['err'] == 1
|
|
549 |
assert resp.json['reason'] == 'all slots must have the same meeting type id (1)'
|
|
550 |
|
393 |
551 |
def test_booking_api_meeting_across_daylight_saving_time(app, meetings_agenda, user):
|
394 |
552 |
meetings_agenda.maximal_booking_delay = 365
|
395 |
553 |
meetings_agenda.save()
|
... | ... | |
746 |
904 |
assert Event.objects.get(id=event.id).booked_places == 3
|
747 |
905 |
assert Event.objects.get(id=event.id).waiting_list == 2
|
748 |
906 |
|
|
907 |
def test_multiple_booking_api_fillslots(app, some_data, user):
|
|
908 |
agenda = Agenda.objects.filter(label=u'Foo bar')[0]
|
|
909 |
# get slots of first 2 events
|
|
910 |
events = [x for x in Event.objects.filter(agenda=agenda).order_by('start_datetime') if x.in_bookable_period()][:2]
|
|
911 |
events_ids = [x.id for x in events]
|
|
912 |
resp_datetimes = app.get('/api/agenda/%s/datetimes/' % agenda.id)
|
|
913 |
slots = [x['id'] for x in resp_datetimes.json['data'] if x['id'] in events_ids]
|
|
914 |
|
|
915 |
app.authorization = ('Basic', ('john.doe', 'password'))
|
|
916 |
resp = app.post('/api/agenda/%s/fillslots/?count=NaN' % agenda.slug, params={'slots': slots}, status=400)
|
|
917 |
assert resp.json['err'] == 1
|
|
918 |
assert resp.json['reason'] == "invalid value for count (NaN)"
|
|
919 |
|
|
920 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug,
|
|
921 |
params={'slots': slots, 'count': 'NaN'}, status=400)
|
|
922 |
assert resp.json['err'] == 1
|
|
923 |
assert resp.json['reason'] == "invalid payload"
|
|
924 |
assert 'count' in resp.json['errors']
|
|
925 |
|
|
926 |
# get 3 places on 2 slots
|
|
927 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug,
|
|
928 |
params={'slots': slots, 'count': '3'})
|
|
929 |
# one booking with 5 children
|
|
930 |
booking = Booking.objects.get(id=resp.json['booking_id'])
|
|
931 |
cancel_url = resp.json['api']['cancel_url']
|
|
932 |
assert Booking.objects.filter(primary_booking=booking).count() == 5
|
|
933 |
assert resp.json['datetime'] == localtime(events[0].start_datetime).isoformat()
|
|
934 |
assert 'accept_url' not in resp.json['api']
|
|
935 |
assert 'cancel_url' in resp.json['api']
|
|
936 |
for event in events:
|
|
937 |
assert Event.objects.get(id=event.id).booked_places == 3
|
|
938 |
|
|
939 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug,
|
|
940 |
params={'slots': slots, 'count': 2})
|
|
941 |
for event in events:
|
|
942 |
assert Event.objects.get(id=event.id).booked_places == 5
|
|
943 |
|
|
944 |
resp = app.post(cancel_url)
|
|
945 |
for event in events:
|
|
946 |
assert Event.objects.get(id=event.id).booked_places == 2
|
|
947 |
|
|
948 |
# check available places overflow
|
|
949 |
# NB: limit only the first event !
|
|
950 |
events[0].places = 3
|
|
951 |
events[0].waiting_list_places = 8
|
|
952 |
events[0].save()
|
|
953 |
|
|
954 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug,
|
|
955 |
params={'slots': slots, 'count': 5})
|
|
956 |
for event in events:
|
|
957 |
assert Event.objects.get(id=event.id).booked_places == 2
|
|
958 |
assert Event.objects.get(id=event.id).waiting_list == 5
|
|
959 |
accept_url = resp.json['api']['accept_url']
|
|
960 |
|
|
961 |
return
|
|
962 |
|
|
963 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug,
|
|
964 |
params={'slots': slots, 'count': 5})
|
|
965 |
assert resp.json['err'] == 1
|
|
966 |
assert resp.json['reason'] == 'sold out'
|
|
967 |
for event in events:
|
|
968 |
assert Event.objects.get(id=event.id).booked_places == 2
|
|
969 |
assert Event.objects.get(id=event.id).waiting_list == 5
|
|
970 |
|
|
971 |
# accept the waiting list
|
|
972 |
resp = app.post(accept_url)
|
|
973 |
for event in events:
|
|
974 |
assert Event.objects.get(id=event.id).booked_places == 7
|
|
975 |
assert Event.objects.get(id=event.id).waiting_list == 0
|
|
976 |
|
|
977 |
# check with a short waiting list
|
|
978 |
Booking.objects.all().delete()
|
|
979 |
# NB: limit only the first event !
|
|
980 |
events[0].places = 4
|
|
981 |
events[0].waiting_list_places = 2
|
|
982 |
events[0].save()
|
|
983 |
|
|
984 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug,
|
|
985 |
params={'slots': slots, 'count': 5})
|
|
986 |
assert resp.json['err'] == 1
|
|
987 |
assert resp.json['reason'] == 'sold out'
|
|
988 |
|
|
989 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug,
|
|
990 |
params={'slots': slots, 'count': 3})
|
|
991 |
assert resp.json['err'] == 0
|
|
992 |
for event in events:
|
|
993 |
assert Event.objects.get(id=event.id).booked_places == 3
|
|
994 |
assert Event.objects.get(id=event.id).waiting_list == 0
|
|
995 |
|
|
996 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug,
|
|
997 |
params={'slots': slots, 'count': 3})
|
|
998 |
assert resp.json['err'] == 1
|
|
999 |
assert resp.json['reason'] == 'sold out'
|
|
1000 |
|
|
1001 |
resp = app.post('/api/agenda/%s/fillslots/' % agenda.slug,
|
|
1002 |
params={'slots': slots, 'count': '2'})
|
|
1003 |
assert resp.json['err'] == 0
|
|
1004 |
for event in events:
|
|
1005 |
assert Event.objects.get(id=event.id).booked_places == 3
|
|
1006 |
assert Event.objects.get(id=event.id).waiting_list == 2
|
|
1007 |
|
749 |
1008 |
def test_agenda_detail_api(app, some_data):
|
750 |
1009 |
agenda = Agenda.objects.get(slug='foo-bar')
|
751 |
1010 |
resp = app.get('/api/agenda/%s/' % agenda.slug)
|
... | ... | |
898 |
1157 |
app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type.id)
|
899 |
1158 |
assert queries_count_datetime1 == len(ctx.captured_queries)
|
900 |
1159 |
|
|
1160 |
def test_agenda_meeting_api_fillslots_multiple_desks(app, meetings_agenda, user):
|
|
1161 |
app.authorization = ('Basic', ('john.doe', 'password'))
|
|
1162 |
agenda_id = meetings_agenda.slug
|
|
1163 |
meeting_type = MeetingType.objects.get(agenda=meetings_agenda)
|
|
1164 |
|
|
1165 |
# add a second desk, same timeperiods
|
|
1166 |
time_period = meetings_agenda.desk_set.first().timeperiod_set.first()
|
|
1167 |
desk2 = Desk.objects.create(label='Desk 2', agenda=meetings_agenda)
|
|
1168 |
TimePeriod.objects.create(
|
|
1169 |
start_time=time_period.start_time, end_time=time_period.end_time,
|
|
1170 |
weekday=time_period.weekday, desk=desk2)
|
|
1171 |
|
|
1172 |
resp = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type.id)
|
|
1173 |
slots = [x['id'] for x in resp.json['data'][:3]]
|
|
1174 |
|
|
1175 |
def get_free_places():
|
|
1176 |
resp = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type.id)
|
|
1177 |
return len([x for x in resp.json['data'] if not x['disabled']])
|
|
1178 |
start_free_places = get_free_places()
|
|
1179 |
|
|
1180 |
# booking 3 slots on desk 1
|
|
1181 |
fillslots_url = '/api/agenda/%s/fillslots/' % agenda_id
|
|
1182 |
resp = app.post(fillslots_url, params={'slots': slots})
|
|
1183 |
assert resp.json['err'] == 0
|
|
1184 |
desk1 = resp.json['desk']['slug']
|
|
1185 |
cancel_url = resp.json['api']['cancel_url']
|
|
1186 |
assert get_free_places() == start_free_places
|
|
1187 |
|
|
1188 |
# booking same slots again, will be on desk 2
|
|
1189 |
resp = app.post(fillslots_url, params={'slots': slots})
|
|
1190 |
assert resp.json['err'] == 0
|
|
1191 |
assert resp.json['desk']['slug'] != desk2
|
|
1192 |
# 3 places are disabled in datetimes list
|
|
1193 |
assert get_free_places() == start_free_places - len(slots)
|
|
1194 |
|
|
1195 |
# try booking again: no desk available
|
|
1196 |
resp = app.post(fillslots_url, params={'slots': slots})
|
|
1197 |
assert resp.json['err'] == 1
|
|
1198 |
assert resp.json['reason'] == 'no more desk available'
|
|
1199 |
assert get_free_places() == start_free_places - len(slots)
|
|
1200 |
|
|
1201 |
# cancel desk 1 booking
|
|
1202 |
resp = app.post(cancel_url)
|
|
1203 |
assert resp.json['err'] == 0
|
|
1204 |
# all places are free again
|
|
1205 |
assert get_free_places() == start_free_places
|
|
1206 |
|
|
1207 |
# booking a single slot (must be on desk 1)
|
|
1208 |
resp = app.post('/api/agenda/%s/fillslot/%s/' % (agenda_id, slots[1]))
|
|
1209 |
assert resp.json['err'] == 0
|
|
1210 |
assert resp.json['desk']['slug'] == desk1
|
|
1211 |
cancel_url = resp.json['api']['cancel_url']
|
|
1212 |
assert get_free_places() == start_free_places - 1
|
|
1213 |
|
|
1214 |
# try booking the 3 slots again: no desk available, one slot is not fully available
|
|
1215 |
resp = app.post(fillslots_url, params={'slots': slots})
|
|
1216 |
assert resp.json['err'] == 1
|
|
1217 |
assert resp.json['reason'] == 'no more desk available'
|
|
1218 |
|
|
1219 |
# cancel last signel slot booking, desk1 will be free
|
|
1220 |
resp = app.post(cancel_url)
|
|
1221 |
assert resp.json['err'] == 0
|
|
1222 |
assert get_free_places() == start_free_places
|
|
1223 |
|
|
1224 |
# booking again is ok, on desk 1
|
|
1225 |
resp = app.post(fillslots_url, params={'slots': slots})
|
|
1226 |
assert resp.json['err'] == 0
|
|
1227 |
assert resp.json['desk']['slug'] == desk1
|
|
1228 |
assert get_free_places() == start_free_places - len(slots)
|
901 |
1229 |
|
902 |
1230 |
def test_agenda_meeting_same_day(app, meetings_agenda, mock_now, user):
|
903 |
1231 |
app.authorization = ('Basic', ('john.doe', 'password'))
|
904 |
|
-
|