0001-api-particulier-more-flexible-validation-for-numero_.patch
passerelle/apps/api_particulier/models.py | ||
---|---|---|
344 | 344 |
}, |
345 | 345 |
) |
346 | 346 |
def v2_situation_familiale(self, request, code_postal, numero_allocataire, user=None): |
347 |
if not code_postal.strip() or not numero_allocataire.strip(): |
|
347 |
numero_allocataire = numero_allocataire.strip()[:7] |
|
348 |
code_postal = code_postal.strip() |
|
349 | ||
350 |
if not code_postal or not numero_allocataire: |
|
348 | 351 |
raise APIError('missing code_postal or numero_allocataire') |
352 | ||
349 | 353 |
if len(numero_allocataire) != 7 or not is_number(numero_allocataire): |
350 | 354 |
raise APIError('numero_allocataire should be a 7 digits number') |
351 | 355 |
return self.get( |
tests/test_api_particulier.py | ||
---|---|---|
338 | 338 |
assert resp.json['err'] == 1 |
339 | 339 |
assert '7 digits' in resp.json['err_desc'] |
340 | 340 | |
341 |
# last letter truncated automatically |
|
342 |
params['numero_allocataire'] = '1234567a' |
|
343 |
resp = endpoint_get( |
|
344 |
'/api-particulier/test/situation-familiale', app, resource, 'situation-familiale', params=params |
|
345 |
) |
|
346 |
assert resp.json['data']['adresse']['codePostalVille'] == '12345 CONDAT' |
|
347 | ||
341 | 348 |
params['code_postal'] = ' ' |
342 | 349 |
resp = endpoint_get( |
343 | 350 |
'/api-particulier/test/situation-familiale', app, resource, 'situation-familiale', params=params |
344 |
- |