From 221a4051f9039068b3b75d7641f11301d6a46d50 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Thu, 17 Dec 2020 14:27:57 +0100 Subject: [PATCH] api: match StringOrListField max length with model definition (#48586) --- chrono/api/views.py | 2 +- tests/test_api.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/chrono/api/views.py b/chrono/api/views.py index e9f516b..43076a1 100644 --- a/chrono/api/views.py +++ b/chrono/api/views.py @@ -753,7 +753,7 @@ class SlotsSerializer(SlotSerializer): slots list is in the payload. ''' - slots = StringOrListField(required=True, child=serializers.CharField(max_length=64, allow_blank=False)) + slots = StringOrListField(required=True, child=serializers.CharField(max_length=160, allow_blank=False)) class Fillslots(APIView): diff --git a/tests/test_api.py b/tests/test_api.py index f139200..0cec7ba 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1213,6 +1213,14 @@ def test_booking_api_fillslots_slots_string_param(app, some_data, user): Booking.objects.get(id=primary_booking_id) assert Booking.objects.count() == 3 + start = now() + datetime.timedelta(days=2) + Event.objects.create(label='Long Slug', slug='a' * 100, start_datetime=start, places=2, agenda=agenda) + Event.objects.create(label='Long Slug', slug='b' * 100, start_datetime=start, places=2, agenda=agenda) + events_ids = [x.id for x in Event.objects.filter(label='Long Slug')] + slots_string_param = ','.join([str(e) for e in events_ids]) + resp = app.post_json('/api/agenda/%s/fillslots/' % agenda.slug, params={'slots': slots_string_param}) + assert Booking.objects.count() == 5 + def test_booking_api_meeting(app, meetings_agenda, user): agenda_id = meetings_agenda.slug -- 2.20.1