agendas: add test on waiting list places using lock code (#89266)
gitea/chrono/pipeline/head This commit looks good Details

This commit is contained in:
Nicolas Roche 2024-04-08 18:17:02 +02:00
parent 8aff0afbcf
commit bfc6b4ad82
1 changed files with 52 additions and 0 deletions

View File

@ -859,3 +859,55 @@ def test_api_events_fillslots_with_lock_code_expiration(app, user, freezer):
assert response.json['data'][0]['places']['reserved'] == 0
assert response.json['data'][1]['places']['available'] == 2
assert response.json['data'][1]['places']['reserved'] == 0
def test_waitin_list_places_using_lock_code(app, user, freezer):
agenda = build_event_agenda(
events={
'Event 1': {
'start_datetime': now() + datetime.timedelta(days=1),
'places': 1,
}
}
)
event = Event.objects.get(agenda=agenda)
event.waiting_list_places = 5
event.save()
# list events
resp = app.get(agenda.get_datetimes_url())
slot = resp.json['data'][0]
assert slot['places']['available'] == 1
assert slot['places']['full'] is False
# book first one
fillslot_url = slot['api']['fillslot_url']
app.authorization = ('Basic', ('john.doe', 'password'))
resp = app.post_json(fillslot_url)
assert resp.json['err'] == 0
# cancel booking
cancel_url = resp.json['api']['cancel_url']
app.authorization = ('Basic', ('john.doe', 'password'))
resp = app.post_json(cancel_url)
assert resp.json['err'] == 0
# list events without lock code
resp = app.get(agenda.get_datetimes_url())
slot = resp.json['data'][0]
assert slot['places'] == {
'total': 1,
'reserved': 0,
'available': 1,
'full': False,
'has_waiting_list': True,
'waiting_list_total': 5,
'waiting_list_reserved': 0,
'waiting_list_available': 5,
'waiting_list_activated': False,
}
# list events with lock code
resp = app.get(agenda.get_datetimes_url(), params={'lock_code': 'MYLOCK', 'hide_disabled': 'true'})
slot2 = resp.json['data'][0]
assert slot2 == slot