tests: add check for a change in opening hours

This commit is contained in:
Frédéric Péters 2017-12-18 21:08:45 +01:00
parent 6d4afedc47
commit 236c1fc3e7
1 changed files with 29 additions and 0 deletions

View File

@ -1124,3 +1124,32 @@ def test_agenda_meeting_gcd_durations_and_exceptions(app, meetings_agenda, user)
assert len(resp.json['data']) == 1
resp = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type_40.id)
assert len(resp.json['data']) == 0
def test_datetimes_api_meetings_agenda_start_hour_change(app, meetings_agenda):
meeting_type = MeetingType.objects.get(agenda=meetings_agenda)
api_url = '/api/agenda/%s/meetings/%s/datetimes/' % (
meeting_type.agenda.slug, meeting_type.slug)
resp = app.get(api_url)
dt = datetime.datetime.strptime(resp.json['data'][2]['id'].split(':')[1], '%Y-%m-%d-%H%M')
ev = Event(agenda=meetings_agenda, meeting_type=meeting_type,
places=1, full=False, start_datetime=make_aware(dt), desk=Desk.objects.first())
ev.save()
booking = Booking(event=ev)
booking.save()
resp = app.get(api_url)
assert len([x for x in resp.json['data'] if x['disabled']]) == 1
desk = Desk.objects.get(label='Desk 1')
# shift opening times by 15 minutes
for timeperiod in desk.timeperiod_set.all():
timeperiod.start_time = timeperiod.start_time.replace(minute=15)
timeperiod.end_time = timeperiod.end_time.replace(minute=15)
timeperiod.save()
# two slots should now be marked as disabled as the previous booking spans
# them.
resp = app.get(api_url)
assert len([x for x in resp.json['data'] if x['disabled']]) == 2