0001-api-add-dedicated-error-handling-for-invalid-place-c.patch
chrono/api/views.py | ||
---|---|---|
312 | 312 |
raise Http404() |
313 | 313 | |
314 | 314 |
if 'count' in request.GET: |
315 |
places_count = int(request.GET['count']) |
|
315 |
try: |
|
316 |
places_count = int(request.GET['count']) |
|
317 |
except ValueError: |
|
318 |
return Response({ |
|
319 |
'err': 1, |
|
320 |
'reason': 'invalid value for count (%r)' % request.GET['count'], |
|
321 |
}) |
|
316 | 322 |
else: |
317 | 323 |
places_count = 1 |
318 | 324 |
tests/test_api.py | ||
---|---|---|
616 | 616 |
event_fillslot_url = [x for x in resp_datetimes.json['data'] if x['id'] == event.id][0]['api']['fillslot_url'] |
617 | 617 | |
618 | 618 |
app.authorization = ('Basic', ('john.doe', 'password')) |
619 |
resp = app.post('/api/agenda/%s/fillslot/%s/?count=NaN' % (agenda.slug, event.id)) |
|
620 |
assert resp.json['err'] == 1 |
|
621 |
assert resp.json['reason'] == "invalid value for count (u'NaN')" |
|
622 | ||
619 | 623 |
resp = app.post('/api/agenda/%s/fillslot/%s/?count=3' % (agenda.slug, event.id)) |
620 | 624 |
Booking.objects.get(id=resp.json['booking_id']) |
621 | 625 |
assert resp.json['datetime'] == localtime(event.start_datetime).isoformat() |
622 |
- |