toulouse-foederis: allow empty phone in create-application (#81728)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
a9f2956db7
commit
9d67f8587a
|
@ -595,13 +595,14 @@ class Resource(BaseResource, HTTPResource):
|
|||
return int(id)
|
||||
|
||||
phone = post_data.get('phone', None)
|
||||
if phone is not None:
|
||||
formatted_phone = ''
|
||||
if phone:
|
||||
try:
|
||||
parsed_phone = phonenumbers.parse(phone, 'FR')
|
||||
except phonenumbers.NumberParseException:
|
||||
raise APIError(_('Couldn\'t recognize provided phone number.'))
|
||||
|
||||
formatted_phone = f'+{parsed_phone.country_code} {parsed_phone.national_number}'
|
||||
formatted_phone = f'+{parsed_phone.country_code} {parsed_phone.national_number}'
|
||||
|
||||
announce_id = _get_id('announce_id')
|
||||
offer_id = None
|
||||
|
|
|
@ -558,6 +558,7 @@ class TestEndpoints:
|
|||
)
|
||||
assert response.json['data']['application_id'] == 42
|
||||
|
||||
def test_create_application_phone_error(self, resource, app):
|
||||
response = app.post_json(
|
||||
'/toulouse-foederis/foederis/create-application',
|
||||
params={'phone': 'mille sabords'},
|
||||
|
@ -565,6 +566,21 @@ class TestEndpoints:
|
|||
assert response.json['err'] == 1
|
||||
assert 'Couldn\'t recognize provided phone number' in response.json['err_desc']
|
||||
|
||||
def test_create_application_empty_phone(self, resource, app):
|
||||
@httmock.urlmatch(path=r'^.*/data/candidature$')
|
||||
def handler(url, request):
|
||||
payload = json.loads(request.body)
|
||||
assert 'telephone' not in payload
|
||||
return httmock.response(200, json.dumps({'code': 200, 'results': [{'id': 42}]}))
|
||||
|
||||
with httmock.HTTMock(handler):
|
||||
response = app.post_json(
|
||||
'/toulouse-foederis/foederis/create-application',
|
||||
params={'phone': ''},
|
||||
)
|
||||
assert response.json['err'] == 0
|
||||
assert response.json['data']['application_id'] == 42
|
||||
|
||||
def test_attach_file(self, resource, app):
|
||||
@httmock.urlmatch(path=r'^.*/data/candidature/424242/fields/cv$')
|
||||
def handler(url, request):
|
||||
|
|
Loading…
Reference in New Issue