api: return a 404 on /status/ for non-existing booking id

This commit is contained in:
Frédéric Péters 2016-07-22 13:45:53 +02:00
parent b7d097dd7b
commit 2da78fd12a
2 changed files with 3 additions and 1 deletions

View File

@ -156,7 +156,7 @@ class SlotStatus(GenericAPIView):
permission_classes = (permissions.IsAuthenticated,)
def get(self, request, agenda_pk=None, event_pk=None, format=None):
event = Event.objects.filter(id=event_pk)[0]
event = get_object_or_404(Event, id=event_pk)
response = {
'err': 0,
'places': {

View File

@ -160,6 +160,8 @@ def test_status(app, some_data, user):
resp = app.get('/api/agenda/%s/status/%s/' % (agenda_id, event.id), status=403)
app.authorization = ('Basic', ('john.doe', 'password'))
resp = app.get('/api/agenda/%s/status/%s/' % (agenda_id, 9999), status=404)
resp = app.get('/api/agenda/%s/status/%s/' % (agenda_id, event.id))
assert resp.json['err'] == 0
assert resp.json['places']['total'] == 10