Projet

Général

Profil

0001-wcs-raise-a-bad-request-when-tracking-code-is-missin.patch

Frédéric Péters, 02 juin 2019 18:11

Télécharger (1,79 ko)

Voir les différences:

Subject: [PATCH] wcs: raise a bad request when tracking code is missing from
 request (#33079)

 combo/apps/wcs/views.py | 2 ++
 tests/test_wcs.py       | 3 +++
 2 files changed, 5 insertions(+)
combo/apps/wcs/views.py
60 60
            cell = TrackingCodeInputCell.objects.get(id=request.POST['cell'])
61 61
        except (KeyError, ValueError, TrackingCodeInputCell.DoesNotExist):
62 62
            return HttpResponseBadRequest('Invalid cell id')
63
        if not 'code' in request.POST:
64
            return HttpResponseBadRequest('Missing code')
63 65
        code = request.POST['code']
64 66

  
65 67
        url = self.search(code, wcs_site=cell.wcs_site)
tests/test_wcs.py
14 14
from django.apps import apps
15 15
from django.conf import settings
16 16
from django.core.cache import cache
17
from django.core.urlresolvers import reverse
17 18
from django.test import override_settings
18 19
from django.test.client import RequestFactory
19 20
from django.utils.six.moves.urllib import parse as urlparse
......
668 669
    resp.form['code'] = 'CNPHNTFB'
669 670
    resp = resp.form.submit(status=400)
670 671

  
672
    resp = app.post(reverse('wcs-tracking-code'), params={'cell': cell.id}, status=400)
673

  
671 674
@wcsctl_present
672 675
def test_cell_assets(app, admin_user):
673 676
    page = Page(title='xxx', slug='test_cell_assets', template_name='standard')
674
-