toulouse-maelis: correct child payload check (#71643)
This commit is contained in:
parent
dd8eea06e9
commit
f05c71c838
|
@ -765,7 +765,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
)
|
||||
def create_child(self, request, NameID, post_data, force=False):
|
||||
family_id = self.get_link(NameID).family_id
|
||||
self.assert_update_coordinate_payload_in_referential(post_data)
|
||||
self.assert_child_payload_in_referential(post_data)
|
||||
|
||||
payload = {
|
||||
'numDossier': family_id,
|
||||
|
|
|
@ -1891,6 +1891,26 @@ def test_create_child_not_linked_error(con, app):
|
|||
assert resp.json['err_desc'] == 'User not linked to family'
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
def test_create_child_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
||||
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
||||
mocked_post.side_effect = []
|
||||
url = get_endpoint('create-child')
|
||||
params = {
|
||||
'lastname': 'DOE',
|
||||
'firstname': 'JANNIS',
|
||||
'sexe': 'plop',
|
||||
'birth/dateBirth': '1943-01-19',
|
||||
'birth/place': 'Port Arthur',
|
||||
}
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local', params=params)
|
||||
assert resp.json['err'] == 'wrong-key'
|
||||
assert resp.json['err_desc'] == "sexe key value 'plop' do not belong to 'Sex' required referential"
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
def test_create_child_connection_error(mocked_post, mocked_get, con, app):
|
||||
|
@ -1968,6 +1988,26 @@ def test_update_child_not_linked_error(con, app):
|
|||
assert resp.json['err_desc'] == 'User not linked to family'
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
def test_update_child_wrong_referential_key_error(mocked_post, mocked_get, con, app):
|
||||
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
||||
mocked_post.side_effect = []
|
||||
url = get_endpoint('create-child')
|
||||
params = {
|
||||
'lastname': 'DOE',
|
||||
'firstname': 'JANNIS',
|
||||
'sexe': 'plop',
|
||||
'birth/dateBirth': '1943-01-19',
|
||||
'birth/place': 'Port Arthur',
|
||||
}
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local', params=params)
|
||||
assert resp.json['err'] == 'wrong-key'
|
||||
assert resp.json['err_desc'] == "sexe key value 'plop' do not belong to 'Sex' required referential"
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
def test_update_child_connection_error(mocked_post, mocked_get, con, app):
|
||||
|
|
Loading…
Reference in New Issue