Projet

Général

Profil

0001-api-match-StringOrListField-max-length-with-model-de.patch

Valentin Deniaud, 17 décembre 2020 14:40

Télécharger (1,79 ko)

Voir les différences:

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(-)
chrono/api/views.py
753 753
    slots list is in the payload.
754 754
    '''
755 755

  
756
    slots = StringOrListField(required=True, child=serializers.CharField(max_length=64, allow_blank=False))
756
    slots = StringOrListField(required=True, child=serializers.CharField(max_length=160, allow_blank=False))
757 757

  
758 758

  
759 759
class Fillslots(APIView):
tests/test_api.py
1213 1213
    Booking.objects.get(id=primary_booking_id)
1214 1214
    assert Booking.objects.count() == 3
1215 1215

  
1216
    start = now() + datetime.timedelta(days=2)
1217
    Event.objects.create(label='Long Slug', slug='a' * 100, start_datetime=start, places=2, agenda=agenda)
1218
    Event.objects.create(label='Long Slug', slug='b' * 100, start_datetime=start, places=2, agenda=agenda)
1219
    events_ids = [x.id for x in Event.objects.filter(label='Long Slug')]
1220
    slots_string_param = ','.join([str(e) for e in events_ids])
1221
    resp = app.post_json('/api/agenda/%s/fillslots/' % agenda.slug, params={'slots': slots_string_param})
1222
    assert Booking.objects.count() == 5
1223

  
1216 1224

  
1217 1225
def test_booking_api_meeting(app, meetings_agenda, user):
1218 1226
    agenda_id = meetings_agenda.slug
1219
-