3619 |
3619 |
)
|
3620 |
3620 |
if next_agenda:
|
3621 |
3621 |
assert booking.event.agenda == next_agenda
|
3622 |
3622 |
|
3623 |
3623 |
foo_num_bookings = Booking.objects.filter(event__desk__agenda=foo_agenda).count()
|
3624 |
3624 |
bar_num_bookings = Booking.objects.filter(event__desk__agenda=bar_agenda).count()
|
3625 |
3625 |
assert foo_num_bookings == 2
|
3626 |
3626 |
assert bar_num_bookings == 4
|
|
3627 |
|
|
3628 |
|
|
3629 |
@pytest.mark.freeze_time('2017-04-01')
|
|
3630 |
def test_duration_on_booking_api_fillslot_response(app, user):
|
|
3631 |
agenda = Agenda(label=u'Foo bar')
|
|
3632 |
agenda.save()
|
|
3633 |
first_date = datetime.datetime(2017, 5, 20, 1, 12)
|
|
3634 |
durations = [None, 0, 45]
|
|
3635 |
evt = []
|
|
3636 |
for i in range(3):
|
|
3637 |
evt.append(Event(
|
|
3638 |
start_datetime=first_date + datetime.timedelta(days=i),
|
|
3639 |
duration=durations[i],
|
|
3640 |
places=20,
|
|
3641 |
agenda=agenda))
|
|
3642 |
evt[i].save()
|
|
3643 |
|
|
3644 |
assert evt[0].end_datetime is None
|
|
3645 |
assert evt[1].end_datetime == evt[1].start_datetime
|
|
3646 |
assert evt[2].end_datetime == evt[2].start_datetime + datetime.timedelta(minutes=45)
|
|
3647 |
app.authorization = ('Basic', ('john.doe', 'password'))
|
|
3648 |
|
|
3649 |
resp = app.post('/api/agenda/%s/fillslot/%s/' % (agenda.slug, evt[0].id))
|
|
3650 |
assert resp.json['datetime'] == '2017-05-20 01:12:00'
|
|
3651 |
assert resp.json['end_datetime'] is None
|
|
3652 |
assert 'ics_url' in resp.json['api']
|
|
3653 |
ics = app.get(resp.json['api']['ics_url']).text
|
|
3654 |
assert 'DTSTART:20170519T231200Z' in ics
|
|
3655 |
assert 'DTEND:' not in ics
|
|
3656 |
|
|
3657 |
resp = app.post('/api/agenda/%s/fillslot/%s/' % (agenda.slug, evt[1].id))
|
|
3658 |
assert resp.json['datetime'] == '2017-05-21 01:12:00'
|
|
3659 |
assert resp.json['end_datetime'] == resp.json['datetime']
|
|
3660 |
assert 'ics_url' in resp.json['api']
|
|
3661 |
ics = app.get(resp.json['api']['ics_url']).text
|
|
3662 |
assert 'DTSTART:20170520T231200Z' in ics
|
|
3663 |
assert 'DTEND:20170520T231200Z' in ics
|
|
3664 |
|
|
3665 |
resp = app.post('/api/agenda/%s/fillslot/%s/' % (agenda.slug, evt[2].id))
|
|
3666 |
assert resp.json['datetime'] == '2017-05-22 01:12:00'
|
|
3667 |
assert resp.json['end_datetime'] == '2017-05-22 01:57:00'
|
|
3668 |
assert 'ics_url' in resp.json['api']
|
|
3669 |
ics = app.get(resp.json['api']['ics_url']).text
|
|
3670 |
assert 'DTSTART:20170521T231200Z' in ics
|
|
3671 |
assert 'DTEND:20170521T235700Z' in ics
|
|
3672 |
|
|
3673 |
|
|
3674 |
@pytest.mark.freeze_time('2017-04-01')
|
|
3675 |
def test_duration_on_booking_api_fillslots_response(app, user):
|
|
3676 |
agenda = Agenda(label=u'Foo bar')
|
|
3677 |
agenda.save()
|
|
3678 |
first_date = datetime.datetime(2017, 5, 20, 1, 12)
|
|
3679 |
durations = [None, 0, 45]
|
|
3680 |
evt = []
|
|
3681 |
for i in range(3):
|
|
3682 |
evt.append(Event(
|
|
3683 |
start_datetime=first_date + datetime.timedelta(days=i),
|
|
3684 |
duration=durations[i],
|
|
3685 |
places=20,
|
|
3686 |
agenda=agenda))
|
|
3687 |
evt[i].save()
|
|
3688 |
|
|
3689 |
assert evt[0].end_datetime is None
|
|
3690 |
assert evt[1].end_datetime == evt[1].start_datetime
|
|
3691 |
assert evt[2].end_datetime == evt[2].start_datetime + datetime.timedelta(minutes=45)
|
|
3692 |
app.authorization = ('Basic', ('john.doe', 'password'))
|
|
3693 |
|
|
3694 |
# first event having null duration
|
|
3695 |
string_param = ','.join([str(e.id) for e in evt[::-1]]) # unordered parameters
|
|
3696 |
resp = app.post_json('/api/agenda/%s/fillslots/' % agenda.slug, params={'slots': string_param})
|
|
3697 |
r_evt = resp.json['events']
|
|
3698 |
|
|
3699 |
assert r_evt[0]['datetime'] == '2017-05-20 01:12:00'
|
|
3700 |
assert r_evt[0]['end_datetime'] is None
|
|
3701 |
assert r_evt[1]['datetime'] == '2017-05-21 01:12:00'
|
|
3702 |
assert r_evt[1]['end_datetime'] == r_evt[1]['datetime']
|
|
3703 |
assert r_evt[2]['datetime'] == '2017-05-22 01:12:00'
|
|
3704 |
assert r_evt[2]['end_datetime'] == '2017-05-22 01:57:00'
|
|
3705 |
assert 'ics_url' in resp.json['api']
|
|
3706 |
ics = app.get(resp.json['api']['ics_url']).text
|
|
3707 |
assert 'DTSTART:20170519T231200Z' in ics
|
|
3708 |
assert 'DTEND:' not in ics
|
|
3709 |
|
|
3710 |
# first event having duration
|
|
3711 |
evt[0].duration = 90
|
|
3712 |
evt[0].save()
|
|
3713 |
resp = app.post_json('/api/agenda/%s/fillslots/' % agenda.slug, params={'slots': string_param})
|
|
3714 |
r_evt = resp.json['events']
|
|
3715 |
|
|
3716 |
assert r_evt[0]['datetime'] == '2017-05-20 01:12:00'
|
|
3717 |
assert r_evt[0]['end_datetime'] == '2017-05-20 02:42:00'
|
|
3718 |
assert 'ics_url' in resp.json['api']
|
|
3719 |
ics = app.get(resp.json['api']['ics_url']).text
|
|
3720 |
assert 'DTSTART:20170519T231200Z' in ics
|
|
3721 |
assert 'DTEND:20170520T004200Z' in ics
|
3627 |
|
-
|