2019-10-06 14:54:02 +02:00
|
|
|
import logging
|
2019-06-11 17:30:31 +02:00
|
|
|
import os
|
2019-10-06 14:54:02 +02:00
|
|
|
import re
|
2022-08-31 10:21:14 +02:00
|
|
|
from unittest import mock
|
2019-06-11 17:30:31 +02:00
|
|
|
|
2019-07-24 16:30:51 +02:00
|
|
|
import pytest
|
2022-08-31 10:21:14 +02:00
|
|
|
from django.utils.encoding import force_bytes, force_str
|
2020-05-20 00:35:06 +02:00
|
|
|
from django.utils.http import urlencode
|
2019-07-24 16:30:51 +02:00
|
|
|
from requests import Request
|
|
|
|
from requests.exceptions import ConnectionError
|
2019-07-08 17:26:17 +02:00
|
|
|
|
2022-03-18 09:46:37 +01:00
|
|
|
import tests.utils
|
2019-06-11 17:30:31 +02:00
|
|
|
from passerelle.apps.astregs.models import AstreGS, Link
|
|
|
|
|
|
|
|
BASE_URL = 'https://test-ws-astre-gs.departement06.fr/axis2/services/'
|
|
|
|
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-07-08 16:58:32 +02:00
|
|
|
def get_xml_file(filename):
|
2020-12-11 09:36:19 +01:00
|
|
|
filepath = os.path.join(os.path.dirname(__file__), 'data', 'astregs', filename)
|
|
|
|
with open(filepath, 'rb') as f:
|
|
|
|
return f.read()
|
2019-07-08 16:58:32 +02:00
|
|
|
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-06-11 17:30:31 +02:00
|
|
|
def contact_search_side_effect(wsdl_url, **kwargs):
|
|
|
|
if 'Tiers' in wsdl_url:
|
2019-07-08 16:58:32 +02:00
|
|
|
response_content = get_xml_file('Tiers.xml')
|
2019-06-11 17:30:31 +02:00
|
|
|
else:
|
2019-07-08 16:58:32 +02:00
|
|
|
response_content = get_xml_file('Contact.xml')
|
2019-06-11 17:30:31 +02:00
|
|
|
return mock.Mock(content=response_content, status_code=200, headers={'Content-Type': 'text/xml'})
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-06-11 17:30:31 +02:00
|
|
|
|
|
|
|
def search_wsdl_side_effect(wsdl_url, **kwargs):
|
|
|
|
if 'Tiers' in wsdl_url:
|
2019-07-08 16:58:32 +02:00
|
|
|
response_content = get_xml_file('Tiers.wsdl')
|
2019-06-11 17:30:31 +02:00
|
|
|
else:
|
2019-07-08 16:58:32 +02:00
|
|
|
response_content = get_xml_file('Contact.wsdl')
|
2019-06-11 17:30:31 +02:00
|
|
|
return mock.Mock(content=response_content, status_code=200, headers={'Content-Type': 'text/xml'})
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-06-11 17:30:31 +02:00
|
|
|
|
2019-07-08 16:58:32 +02:00
|
|
|
def contact_wsdl_side_effect(wsdl_url, **kwargs):
|
|
|
|
if 'ContactAdresses' in wsdl_url:
|
|
|
|
response_content = get_xml_file('ContactAdresses.wsdl')
|
|
|
|
else:
|
|
|
|
response_content = get_xml_file('Contact.wsdl')
|
|
|
|
return mock.Mock(content=response_content, status_code=200, headers={'Content-Type': 'text/xml'})
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-07-08 16:58:32 +02:00
|
|
|
|
|
|
|
def contact_side_effect(wsdl_url, **kwargs):
|
|
|
|
if 'ContactAdresses' in wsdl_url:
|
|
|
|
response_content = get_xml_file('ContactAddressCreationResponse.xml')
|
|
|
|
else:
|
|
|
|
response_content = get_xml_file('ContactCreationResponse.xml')
|
|
|
|
return mock.Mock(content=response_content, status_code=200, headers={'Content-Type': 'text/xml'})
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-06-11 17:30:31 +02:00
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def connector(db):
|
2022-03-18 09:46:37 +01:00
|
|
|
return tests.utils.make_resource(
|
2019-06-11 17:30:31 +02:00
|
|
|
AstreGS,
|
|
|
|
title='Test',
|
|
|
|
slug='test',
|
|
|
|
description='test',
|
|
|
|
wsdl_base_url=BASE_URL,
|
|
|
|
username='CS-FORML',
|
|
|
|
password='secret',
|
|
|
|
organism='CG06',
|
|
|
|
budget='01',
|
|
|
|
exercice='2019',
|
|
|
|
)
|
|
|
|
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-06-28 11:12:04 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def recherche_tiers_details_wsdl():
|
2019-06-27 15:53:51 +02:00
|
|
|
return get_xml_file('RechercheTiersDetails.wsdl')
|
2019-06-28 11:12:04 +02:00
|
|
|
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-06-28 11:12:04 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def recherche_tiers_details_result():
|
2019-06-27 15:53:51 +02:00
|
|
|
return get_xml_file('RechercheTiersDetails.xml')
|
|
|
|
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-10-06 14:54:02 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def recherche_tiers_details_empty_result():
|
|
|
|
content = get_xml_file('RechercheTiersDetails.xml')
|
2020-01-15 14:27:42 +01:00
|
|
|
return force_bytes(re.sub('<ns1:liste>.*</ns1:liste>', '<ns1:liste></ns1:liste>', force_str(content)))
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-10-06 14:54:02 +02:00
|
|
|
|
2019-06-27 15:53:51 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def tiers_creation_response():
|
|
|
|
return get_xml_file('TiersCreationResponse.xml')
|
|
|
|
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2020-09-08 10:56:16 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def tiers_with_no_siret_creation_response():
|
|
|
|
return get_xml_file('TiersWithNoSiretCreationResponse.xml')
|
|
|
|
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-06-27 15:53:51 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def tiers_creation_error_response():
|
|
|
|
return get_xml_file('TiersCreationErrorResponse.xml')
|
2019-06-28 11:12:04 +02:00
|
|
|
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-07-04 15:03:12 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def tiers_response():
|
|
|
|
return get_xml_file('TiersResponse.xml')
|
|
|
|
|
2021-02-20 16:26:01 +01:00
|
|
|
|
2019-07-04 15:03:12 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def tiers_error_response():
|
|
|
|
return get_xml_file('TiersErrorResponse.xml')
|
|
|
|
|
2019-06-11 17:30:31 +02:00
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
2019-06-28 11:12:04 +02:00
|
|
|
def test_search_association_by_siren(
|
|
|
|
mocked_post, mocked_get, recherche_tiers_details_wsdl, recherche_tiers_details_result, connector, app
|
|
|
|
):
|
|
|
|
mocked_get.return_value = mock.Mock(content=recherche_tiers_details_wsdl)
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=recherche_tiers_details_result, status_code=200, headers={'Content-Type': 'text/xml'}
|
2019-06-11 17:30:31 +02:00
|
|
|
)
|
|
|
|
resp = app.get('/astregs/test/associations', params={'siren': '500433909'})
|
|
|
|
assert mocked_get.call_args[0][0] == '%sRechercheTiersDetails?wsdl' % BASE_URL
|
|
|
|
assert mocked_post.call_args[0][0] == '%sRechercheTiersDetails/' % BASE_URL
|
|
|
|
assert isinstance(resp.json['data'], list)
|
|
|
|
assert len(resp.json['data']) > 0
|
|
|
|
assert resp.json['data'][0]['id'] == '50043390900016'
|
|
|
|
assert resp.json['data'][0]['text'] == '50043390900016 - ASSOCIATION OMNISPORTS DES MONTS D AZUR'
|
|
|
|
assert resp.json['data'][0]['code'] == '173957'
|
|
|
|
assert resp.json['data'][0]['name'] == 'ASSOCIATION OMNISPORTS DES MONTS D AZUR'
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_check_association_presence(mocked_post, mocked_get, connector, app):
|
2020-01-15 14:27:42 +01:00
|
|
|
wsdl_content = get_xml_file('RechercheTiers.wsdl')
|
|
|
|
response_content = get_xml_file('RechercheTiers.xml')
|
2019-06-11 17:30:31 +02:00
|
|
|
mocked_get.return_value = mock.Mock(content=wsdl_content)
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=response_content, status_code=200, headers={'Content-Type': 'text/xml'}
|
|
|
|
)
|
|
|
|
resp = app.get('/astregs/test/check-association-by-siret', params={'siret': '50043390900014'})
|
2022-03-18 12:31:05 +01:00
|
|
|
assert resp.json['exists'] is True
|
2020-01-15 14:27:42 +01:00
|
|
|
response_content = get_xml_file('RechercheTiersNoResult.xml')
|
2019-06-11 17:30:31 +02:00
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=response_content, status_code=200, headers={'Content-Type': 'text/xml'}
|
|
|
|
)
|
|
|
|
resp = app.get('/astregs/test/check-association-by-siret', params={'siret': 'unknown'})
|
2022-03-18 12:31:05 +01:00
|
|
|
assert resp.json['exists'] is False
|
2019-06-11 17:30:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get', side_effect=search_wsdl_side_effect)
|
|
|
|
@mock.patch('passerelle.utils.Request.post', side_effect=contact_search_side_effect)
|
|
|
|
def test_association_linking_means(mocked_post, mocked_get, client, connector, app):
|
|
|
|
resp = app.get('/astregs/test/get-association-link-means', params={'association_id': '42'})
|
2022-03-18 12:31:05 +01:00
|
|
|
assert resp.json['already_paired'] is False
|
2019-08-28 17:00:54 +02:00
|
|
|
assert resp.json['data'] == [
|
|
|
|
{
|
|
|
|
'id': 'email',
|
|
|
|
'text': 'par courriel vers fo***@***com',
|
|
|
|
'value': 'foo@example.com',
|
|
|
|
'type': 'email',
|
|
|
|
},
|
|
|
|
{'id': 'mobile', 'text': 'par SMS vers 06*****990', 'value': '0667788990', 'type': 'mobile'},
|
|
|
|
]
|
|
|
|
assert resp.json['raw_data']['AdresseMail'] == 'foo@example.com'
|
|
|
|
assert resp.json['raw_data']['TelephoneMobile'] == '06 67 78 89 90'
|
2019-06-11 17:30:31 +02:00
|
|
|
|
2019-06-28 12:30:30 +02:00
|
|
|
Link.objects.create(name_id='user_name_id', association_id='42', resource=connector)
|
|
|
|
resp = app.get(
|
|
|
|
'/astregs/test/get-association-link-means', params={'association_id': '42', 'NameID': 'user_name_id'}
|
|
|
|
)
|
2022-03-18 12:31:05 +01:00
|
|
|
assert resp.json['already_paired'] is True
|
2019-06-28 12:30:30 +02:00
|
|
|
|
2019-08-28 17:00:54 +02:00
|
|
|
for bad_mobile_number in ('', '01 43 35 01 35', '00 33 7 01 02 03 04', 'letters', '06 01 02'):
|
|
|
|
mocked_post.side_effect = [
|
|
|
|
mock.Mock(
|
|
|
|
content=get_xml_file('Tiers.xml'), status_code=200, headers={'Content-Type': 'text/xml'}
|
|
|
|
),
|
|
|
|
mock.Mock(
|
|
|
|
content=get_xml_file('Contact.xml').replace(
|
2020-01-15 14:27:42 +01:00
|
|
|
b'<ns1:TelephoneMobile>06 67 78 89 90<',
|
|
|
|
b'<ns1:TelephoneMobile>%s<' % force_bytes(bad_mobile_number),
|
2021-02-20 16:26:01 +01:00
|
|
|
),
|
2019-08-28 17:00:54 +02:00
|
|
|
status_code=200,
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
2021-02-20 16:26:01 +01:00
|
|
|
),
|
2019-08-28 17:00:54 +02:00
|
|
|
]
|
|
|
|
resp = app.get('/astregs/test/get-association-link-means', params={'association_id': '42'})
|
|
|
|
assert resp.json['data'] == [
|
|
|
|
{
|
|
|
|
'id': 'email',
|
|
|
|
'text': 'par courriel vers fo***@***com',
|
|
|
|
'value': 'foo@example.com',
|
|
|
|
'type': 'email',
|
|
|
|
}
|
|
|
|
]
|
|
|
|
assert resp.json['raw_data']['AdresseMail'] == 'foo@example.com'
|
|
|
|
assert resp.json['raw_data']['TelephoneMobile'] == (bad_mobile_number or None)
|
2019-06-28 12:30:30 +02:00
|
|
|
|
|
|
|
|
2019-06-11 17:30:31 +02:00
|
|
|
@mock.patch('passerelle.utils.Request.get', side_effect=search_wsdl_side_effect)
|
|
|
|
@mock.patch('passerelle.utils.Request.post', side_effect=contact_search_side_effect)
|
2019-10-15 09:20:32 +02:00
|
|
|
def test_link_user_to_association(
|
|
|
|
mocked_post,
|
|
|
|
mocked_get,
|
|
|
|
client,
|
|
|
|
recherche_tiers_details_wsdl,
|
|
|
|
recherche_tiers_details_result,
|
|
|
|
connector,
|
|
|
|
app,
|
|
|
|
):
|
2019-06-11 17:30:31 +02:00
|
|
|
assert Link.objects.count() == 0
|
|
|
|
resp = app.get('/astregs/test/get-association-link-means', params={'association_id': '42'})
|
2019-07-11 18:30:04 +02:00
|
|
|
assert len(resp.json['data']) == 2
|
2019-10-15 09:20:32 +02:00
|
|
|
mocked_get.side_effect = None
|
|
|
|
mocked_post.side_effect = None
|
|
|
|
mocked_get.return_value = mock.Mock(content=recherche_tiers_details_wsdl)
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=recherche_tiers_details_result, status_code=200, headers={'Content-Type': 'text/xml'}
|
|
|
|
)
|
2019-06-11 17:30:31 +02:00
|
|
|
resp = app.get('/astregs/test/link', params={'association_id': '42', 'NameID': 'user_name_id'})
|
|
|
|
assert Link.objects.filter(name_id='user_name_id', association_id='42').count() == 1
|
|
|
|
link = Link.objects.get(name_id='user_name_id', association_id='42')
|
2019-10-15 09:20:32 +02:00
|
|
|
assert link.association_label == '50043390900016 - ASSOCIATION OMNISPORTS DES MONTS D AZUR'
|
2019-06-11 17:30:31 +02:00
|
|
|
assert resp.json['association_id'] == link.association_id
|
|
|
|
assert resp.json['link'] == link.pk
|
2022-03-18 12:31:05 +01:00
|
|
|
assert resp.json['created'] is True
|
2019-06-11 17:30:31 +02:00
|
|
|
resp = app.get('/astregs/test/link', params={'association_id': '42', 'NameID': 'user_name_id'})
|
2022-03-18 12:31:05 +01:00
|
|
|
assert resp.json['created'] is False
|
2019-06-11 17:30:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get', side_effect=search_wsdl_side_effect)
|
|
|
|
@mock.patch('passerelle.utils.Request.post', side_effect=contact_search_side_effect)
|
2019-10-15 09:20:32 +02:00
|
|
|
def test_unlink_user_from_association(
|
|
|
|
mocked_post, mocked_get, connector, recherche_tiers_details_wsdl, recherche_tiers_details_result, app
|
|
|
|
):
|
2019-06-11 17:30:31 +02:00
|
|
|
resp = app.get('/astregs/test/get-association-link-means', params={'association_id': '42'})
|
2019-10-15 09:20:32 +02:00
|
|
|
mocked_get.side_effect = None
|
|
|
|
mocked_post.side_effect = None
|
|
|
|
mocked_get.return_value = mock.Mock(content=recherche_tiers_details_wsdl)
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=recherche_tiers_details_result, status_code=200, headers={'Content-Type': 'text/xml'}
|
|
|
|
)
|
2019-06-11 17:30:31 +02:00
|
|
|
resp = app.get('/astregs/test/link', params={'association_id': '42', 'NameID': 'user_name_id'})
|
|
|
|
resp = app.get('/astregs/test/unlink', params={'NameID': 'user_name_id', 'association_id': '42'})
|
|
|
|
assert resp.json['deleted']
|
|
|
|
resp = app.get(
|
|
|
|
'/astregs/test/unlink', params={'NameID': 'user_name_id', 'association_id': '42'}, status=404
|
|
|
|
)
|
2019-06-28 11:12:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_list_user_associations(
|
|
|
|
mocked_post,
|
|
|
|
mocked_get,
|
|
|
|
recherche_tiers_details_wsdl,
|
2019-10-06 14:54:02 +02:00
|
|
|
recherche_tiers_details_result,
|
|
|
|
recherche_tiers_details_empty_result,
|
|
|
|
connector,
|
|
|
|
app,
|
|
|
|
caplog,
|
|
|
|
):
|
2019-06-28 11:12:04 +02:00
|
|
|
mocked_get.return_value = mock.Mock(content=recherche_tiers_details_wsdl)
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=recherche_tiers_details_result, status_code=200, headers={'Content-Type': 'text/xml'}
|
|
|
|
)
|
|
|
|
resp = app.get('/astregs/test/link', params={'association_id': '42', 'NameID': 'user_name_id'})
|
|
|
|
resp = app.get('/astregs/test/links', params={'NameID': 'user_name_id'})
|
2019-10-06 14:54:02 +02:00
|
|
|
mocked_get.assert_called()
|
|
|
|
mocked_post.assert_called()
|
|
|
|
assert resp.json['data']
|
|
|
|
assert resp.json['data'][0]['id'] == '42'
|
|
|
|
assert resp.json['data'][0]['text'] == '50043390900016 - ASSOCIATION OMNISPORTS DES MONTS D AZUR'
|
|
|
|
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=recherche_tiers_details_empty_result, status_code=200, headers={'Content-Type': 'text/xml'}
|
|
|
|
)
|
|
|
|
resp = app.get('/astregs/test/links', params={'NameID': 'user_name_id'})
|
2019-06-28 11:12:04 +02:00
|
|
|
assert resp.json['data']
|
|
|
|
assert resp.json['data'][0]['id'] == '42'
|
|
|
|
assert resp.json['data'][0]['text'] == '50043390900016 - ASSOCIATION OMNISPORTS DES MONTS D AZUR'
|
2019-10-06 14:54:02 +02:00
|
|
|
assert len(caplog.records)
|
|
|
|
assert caplog.records[-1].levelno == logging.ERROR
|
|
|
|
assert caplog.records[-1].message == 'No data found for association 42'
|
2019-06-27 15:53:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get', side_effect=search_wsdl_side_effect)
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_association_creation(
|
|
|
|
mocked_post, mocked_get, tiers_creation_response, tiers_creation_error_response, connector, app
|
|
|
|
):
|
2019-07-09 09:52:13 +02:00
|
|
|
payload = {
|
|
|
|
'CodeFamille': '51',
|
|
|
|
'CatTiers': '42',
|
|
|
|
'EncodeKeyContact': '4242',
|
|
|
|
'Sigle': 'EO',
|
|
|
|
'NomEnregistrement': 'My association',
|
|
|
|
'Organisme': 'CG06',
|
|
|
|
'NumeroSiret': '112233445',
|
|
|
|
'NumeroSiretFin': '00024',
|
|
|
|
'StatutTiers': 'PROPOSE',
|
|
|
|
'Type': '*',
|
|
|
|
'AdresseTitre': 'AdressePrincipale',
|
|
|
|
'AdresseLibelleRue': '169, rue du Château',
|
|
|
|
'Financier': 'true',
|
|
|
|
'AdresseIsAdresseDeFacturation': 'false',
|
|
|
|
'AdresseIsAdresseDeCommande': 'false',
|
2019-06-27 15:53:51 +02:00
|
|
|
}
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=tiers_creation_response, status_code=200, headers={'Content-Type': 'text/xml'}
|
|
|
|
)
|
|
|
|
resp = app.post_json('/astregs/test/create-association', params=payload)
|
|
|
|
assert resp.json['data']
|
|
|
|
data = resp.json['data']
|
2019-07-08 17:26:17 +02:00
|
|
|
assert data['CodeTiers'] == '487464'
|
|
|
|
assert data['CodeFamille'] == '51'
|
|
|
|
assert data['CatTiers'] == '42'
|
2019-07-08 17:27:53 +02:00
|
|
|
assert data['EncodeKeyContact'] == '4242'
|
2019-07-08 17:26:17 +02:00
|
|
|
assert data['NomEnregistrement'] == 'My association'
|
|
|
|
assert data['Organisme'] == 'CG06'
|
|
|
|
assert data['NumeroSiret'] == '112233445'
|
|
|
|
assert data['NumeroSiretFin'] == '00024'
|
|
|
|
assert data['StatutTiers'] == 'PROPOSE'
|
|
|
|
assert data['Type'] == '*'
|
|
|
|
assert data['AdresseTitre'] == 'AdressePrincipale'
|
2022-08-31 10:21:14 +02:00
|
|
|
assert data['AdresseLibelleRue'] == force_str('169, rue du Château')
|
2019-07-09 09:52:13 +02:00
|
|
|
assert data['Sigle'] == 'EO'
|
|
|
|
assert data['AdresseIsAdresseDeCommande'] == 'false'
|
|
|
|
assert data['AdresseIsAdresseDeFacturation'] == 'false'
|
2019-06-27 15:53:51 +02:00
|
|
|
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=tiers_creation_error_response, status_code=500, headers={'Content-Type': 'text/xml'}
|
2019-07-09 12:35:12 +02:00
|
|
|
)
|
|
|
|
resp = app.post_json('/astregs/test/create-association', params=payload)
|
2019-06-27 15:53:51 +02:00
|
|
|
assert resp.json['err'] == 1
|
2019-07-09 12:35:12 +02:00
|
|
|
assert resp.json['err_class'] == 'passerelle.utils.jsonresponse.APIError'
|
|
|
|
assert "Erreur technique dans le service 'Tiers'" in resp.json['err_desc']
|
2019-06-27 15:53:51 +02:00
|
|
|
assert not resp.json['data']
|
2019-07-04 15:03:12 +02:00
|
|
|
|
|
|
|
|
2020-09-08 10:56:16 +02:00
|
|
|
@mock.patch('passerelle.utils.Request.get', side_effect=search_wsdl_side_effect)
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_tiers_creation(
|
|
|
|
mocked_post,
|
|
|
|
mocked_get,
|
|
|
|
tiers_with_no_siret_creation_response,
|
|
|
|
tiers_creation_error_response,
|
|
|
|
connector,
|
|
|
|
app,
|
|
|
|
):
|
|
|
|
payload = {
|
|
|
|
'CodeFamille': '51',
|
|
|
|
'CatTiers': '42',
|
|
|
|
'EncodeKeyContact': '4242',
|
|
|
|
'Sigle': 'EO',
|
|
|
|
'NomEnregistrement': 'MY TIERS',
|
|
|
|
'Organisme': 'CG06',
|
|
|
|
'StatutTiers': 'PROPOSE',
|
|
|
|
'Type': '*',
|
|
|
|
'AdresseTitre': 'AdressePrincipale',
|
|
|
|
'AdresseLibelleRue': '169, rue du Château',
|
|
|
|
'AdresseDestinataire': '169, rue du Château',
|
|
|
|
'Financier': 'true',
|
|
|
|
'AdresseIsAdresseDeFacturation': 'false',
|
|
|
|
'AdresseIsAdresseDeCommande': 'false',
|
|
|
|
}
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=tiers_with_no_siret_creation_response, status_code=200, headers={'Content-Type': 'text/xml'}
|
|
|
|
)
|
|
|
|
resp = app.post_json('/astregs/test/create-association', params=payload)
|
|
|
|
assert resp.json['data']
|
|
|
|
data = resp.json['data']
|
|
|
|
assert data['CodeTiers'] == '492269'
|
|
|
|
assert data['CodeFamille'] == '51'
|
|
|
|
assert data['CatTiers'] == '42'
|
|
|
|
assert data['EncodeKeyContact'] == '4242'
|
|
|
|
assert data['NomEnregistrement'] == 'MY TIERS'
|
|
|
|
assert data['StatutTiers'] == 'PROPOSE'
|
|
|
|
|
|
|
|
|
2019-07-04 15:03:12 +02:00
|
|
|
@mock.patch('passerelle.utils.Request.get', side_effect=search_wsdl_side_effect)
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_get_association_by_id(mocked_post, mocked_get, tiers_response, tiers_error_response, connector, app):
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=tiers_response, status_code=200, headers={'Content-Type': 'text/xml'}
|
|
|
|
)
|
2019-07-08 10:05:58 +02:00
|
|
|
|
2019-07-04 15:03:12 +02:00
|
|
|
resp = app.get('/astregs/test/get-association-by-id', params={'association_id': '487464'})
|
|
|
|
assert resp.json['data']
|
|
|
|
data = resp.json['data']
|
2022-03-18 14:35:33 +01:00
|
|
|
assert data['CodeTiers'] == '487464'
|
|
|
|
assert data['CodeFamille'] == '51'
|
|
|
|
assert data['CatTiers'] == '42'
|
|
|
|
assert data['NomEnregistrement'] == 'My association'
|
|
|
|
assert data['Organisme'] == 'CG06'
|
|
|
|
assert data['NumeroSiret'] == '112233445'
|
|
|
|
assert data['NumeroSiretFin'] == '00024'
|
|
|
|
assert data['StatutTiers'] == 'PROPOSE'
|
2019-07-08 10:05:58 +02:00
|
|
|
|
|
|
|
resp = app.get(
|
|
|
|
'/astregs/test/get-association-by-id',
|
|
|
|
params={'association_id': '487464', 'NameID': 'user_name_id'},
|
|
|
|
status=404,
|
|
|
|
)
|
|
|
|
|
|
|
|
Link.objects.create(name_id='user_name_id', association_id='487464', resource=connector)
|
|
|
|
resp = app.get(
|
|
|
|
'/astregs/test/get-association-by-id', params={'association_id': '487464', 'NameID': 'user_name_id'}
|
|
|
|
)
|
|
|
|
assert resp.json['data']
|
2019-07-04 15:03:12 +02:00
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=tiers_error_response, status_code=500, headers={'Content-Type': 'text/xml'}
|
|
|
|
)
|
2019-07-09 12:35:12 +02:00
|
|
|
resp = app.get('/astregs/test/get-association-by-id', params={'association_id': 'unknown'}, status=200)
|
2019-07-04 15:03:12 +02:00
|
|
|
assert resp.json['err'] == 1
|
2019-07-09 12:35:12 +02:00
|
|
|
assert resp.json['err_class'] == 'passerelle.utils.jsonresponse.APIError'
|
|
|
|
assert "Erreur technique dans le service 'Tiers'" in resp.json['err_desc']
|
2019-07-04 15:03:12 +02:00
|
|
|
assert not resp.json['data']
|
2019-07-08 16:58:32 +02:00
|
|
|
|
|
|
|
|
2019-08-05 11:38:10 +02:00
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_get_contact_details(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('Contact.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('ContactResponse.xml'), status_code=200, headers={'Content-Type': 'text/xml'}
|
|
|
|
)
|
|
|
|
resp = app.get('/astregs/test/get-contact', params={'contact_id': '1111'})
|
|
|
|
assert resp.json['err'] == 0
|
|
|
|
assert resp.json['data']
|
|
|
|
data = resp.json['data']
|
|
|
|
assert data['idContact'] == '1111'
|
|
|
|
assert data['CodeContact'] == 'POL14466'
|
|
|
|
assert data['Nom'] == 'NARDELLI'
|
|
|
|
assert data['Prenom'] == 'Robert'
|
|
|
|
assert data['ComplementGeographique'] == 'Mairie'
|
|
|
|
assert data['CodePostal'] == '06340'
|
|
|
|
assert data['Ville'] == 'DRAP'
|
|
|
|
assert data['LibellePays'] == 'France'
|
|
|
|
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('ContactResponse.xml'), status_code=500, headers={'Content-Type': 'text/xml'}
|
|
|
|
)
|
|
|
|
resp = app.get('/astregs/test/get-contact', params={'contact_id': '4242'})
|
|
|
|
assert not resp.json['data']
|
|
|
|
assert resp.json['err'] == 1
|
|
|
|
assert resp.json['err_class'] == 'passerelle.utils.jsonresponse.APIError'
|
|
|
|
|
|
|
|
|
2019-07-24 16:30:51 +02:00
|
|
|
@mock.patch('passerelle.utils.Request.get', side_effect=ConnectionError('mocked error', request=Request()))
|
|
|
|
@mock.patch('passerelle.utils.Request.post', side_effect=NotImplementedError)
|
|
|
|
def test_low_level_connection_error(
|
|
|
|
mocked_post, mocked_get, tiers_response, tiers_error_response, connector, app
|
|
|
|
):
|
|
|
|
resp = app.get('/astregs/test/get-association-by-id', params={'association_id': '487464'})
|
|
|
|
assert resp.json['err'] == 1
|
|
|
|
assert resp.json['data'] is None
|
|
|
|
assert 'mocked error' in resp.json['err_desc']
|
|
|
|
|
|
|
|
|
2019-07-08 16:58:32 +02:00
|
|
|
@mock.patch('passerelle.utils.Request.get', side_effect=contact_wsdl_side_effect)
|
|
|
|
@mock.patch('passerelle.utils.Request.post', side_effect=contact_side_effect)
|
|
|
|
def test_create_association_contact(mocked_post, mocked_get, connector, app):
|
|
|
|
payload = {
|
2019-07-09 10:19:37 +02:00
|
|
|
'AdresseDestinataire': '169 rue du Ch\xc3\xa2teau',
|
|
|
|
'Ville': 'Nice',
|
|
|
|
'CodeContact': 'AS207002',
|
|
|
|
'Commentaire': 'Contact creation',
|
2019-07-08 16:58:32 +02:00
|
|
|
'country_code': 'FR',
|
2019-07-09 10:19:37 +02:00
|
|
|
'AdresseMail': 'foo@example.com',
|
|
|
|
'Prenom': 'Foo',
|
|
|
|
'Nom': 'Bar',
|
|
|
|
'TelephoneMobile': '0607080900',
|
|
|
|
'TelephoneBureau': '0102030405',
|
|
|
|
'CodeTitreCivilite': '035',
|
|
|
|
'PageWeb': 'http://example.com',
|
|
|
|
'CodePostal': '06000',
|
|
|
|
'CodeFonction': '01',
|
|
|
|
'EncodeKeyStatut': 'VALIDE',
|
2019-07-08 16:58:32 +02:00
|
|
|
}
|
|
|
|
resp = app.post_json('/astregs/test/create-contact', params=payload)
|
|
|
|
assert resp.json['data']
|
|
|
|
data = resp.json['data']
|
|
|
|
assert data['idContact'] == '437309'
|
|
|
|
assert data['Prenom'] == 'Foo'
|
|
|
|
assert data['Nom'] == 'Bar'
|
2019-07-09 12:06:03 +02:00
|
|
|
assert data['CodeFonction'] == '01'
|
2019-07-08 16:58:32 +02:00
|
|
|
assert data['PageWeb'] == 'http://example.com'
|
|
|
|
assert data['AdresseMail'] == 'foo@example.com'
|
|
|
|
assert data['LibellePays'] == 'France'
|
|
|
|
assert data['CodePays'] == 'FR'
|
|
|
|
assert data['CodeTitreCivilite'] == '035'
|
|
|
|
assert data['CodeContact'] == 'AS207002'
|
|
|
|
assert data['TelephoneBureau'] == '0102030405'
|
|
|
|
assert data['TelephoneMobile'] == '0607080900'
|
2019-07-08 18:47:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_delete_association_contact(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('Contact.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('ContactDeletionResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
resp = app.get('/astregs/test/delete-contact', params={'contact_id': '437307'})
|
|
|
|
assert resp.json['data']
|
|
|
|
# if contact is deleted the its id is None
|
|
|
|
assert resp.json['data']['idContact'] is None
|
2019-07-10 10:43:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_create_document(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('DocumentAnnexe.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('DocumentCreationResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
payload = {
|
|
|
|
'Sujet': 'Test',
|
|
|
|
'Entite': 'COMMANDE',
|
|
|
|
'CodType': 'COMMANDE',
|
|
|
|
'Type': 'Type label',
|
|
|
|
'hdnCodeTrt': 'UPDATE',
|
|
|
|
'EncodeKeyEntite': '|25901|',
|
|
|
|
'CodeDomaine': 'GF',
|
|
|
|
'CodDom': 'GF',
|
|
|
|
'Metadonnees': '|Organisme *CG06|Code Tiers *1|',
|
|
|
|
'document': {
|
|
|
|
'filename': 'test.pdf',
|
|
|
|
'content_type': 'application/pdf',
|
|
|
|
'content': 'base64encodedcontent',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
resp = app.post_json('/astregs/test/create-document', params=payload)
|
|
|
|
assert resp.json['data']
|
|
|
|
assert resp.json['data']['RefDocument'] == '111'
|
|
|
|
assert resp.json['data']['NumVersion'] == '1'
|
2019-07-11 12:01:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_create_grant_demand(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('Dossier.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('DossierCreationResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
payload = {
|
|
|
|
'Libelle': 'test grant demand',
|
|
|
|
'LibelleCourt': 'test',
|
|
|
|
'ModGestion': '1',
|
|
|
|
'TypeAide': 'F',
|
|
|
|
'Sens': 'D',
|
|
|
|
'CodeTiersDem': '487473',
|
|
|
|
'CodeServiceGestionnaire': 'SGG',
|
|
|
|
'CodeAide': '030105',
|
|
|
|
'CodeServiceUtilisateur': '030105',
|
|
|
|
}
|
|
|
|
resp = app.post_json('/astregs/test/create-grant-demand', params=payload)
|
|
|
|
assert resp.json['data']
|
|
|
|
data = resp.json['data']
|
|
|
|
assert data['CodeDossier'] == '2019_06407'
|
|
|
|
assert data['Exercice'] == '2019'
|
|
|
|
assert data['Libelle'] == 'test grant demand'
|
|
|
|
assert data['LibelleCourt'] == 'test'
|
|
|
|
assert data['ModGestion'] == '1'
|
|
|
|
assert data['CodeServiceGestionnaire'] == 'SGG'
|
|
|
|
assert data['CodeServiceUtilisateur'] == 'SUG4'
|
|
|
|
assert data['LibelleServiceUtilisateur'] == 'SPORTS ET JEUNESSE'
|
|
|
|
assert data['TypeAide'] == 'F'
|
|
|
|
assert data['CodeAide'] == '030105'
|
|
|
|
assert data['LibelleAide'] == 'Actions culturelles - Etab publics locaux'
|
|
|
|
assert data['Sens'] == 'D'
|
|
|
|
assert data['CodeTiersDem'] == '487463'
|
|
|
|
assert data['NomTiersDem'] == 'My Tiers'
|
|
|
|
assert data['CodeStatut'] == 'ENR'
|
|
|
|
assert data['DateCreation'] == '11/07/2019'
|
2019-07-30 11:48:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_create_indana_indicator(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('DossierIndicateur.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('DossierIndicateurCreationResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
payload = {'CodeDossier': '2019_06407', 'CodeInd_1': '501', 'AnneeInd_1': '2019', 'ValInd_1': 'O'}
|
|
|
|
resp = app.post_json('/astregs/test/create-indana-indicator', params=payload)
|
|
|
|
assert resp.json['err'] == 0
|
|
|
|
assert resp.json['data']
|
|
|
|
data = resp.json['data']
|
|
|
|
assert data['CodeDossier'] == '2019_06407'
|
|
|
|
assert data['CodeInd_1'] == '501'
|
|
|
|
assert data['AnneeInd_1'] == '2019'
|
|
|
|
assert data['ValInd_1'] == 'O'
|
|
|
|
assert data['IndAide'] == 'Non'
|
2019-08-28 11:29:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_update_indana_indicator(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('DossierIndicateur.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('DossierIndicateurModificationResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
payload = {'CodeDossier': '2019_06407', 'CodeInd_1': '501', 'AnneeInd_1': '2019', 'ValInd_1': 'N'}
|
|
|
|
resp = app.post_json('/astregs/test/update-indana-indicator', params=payload)
|
|
|
|
assert resp.json == {
|
|
|
|
'err': 0,
|
|
|
|
'data': {
|
|
|
|
'CodeDossier': '2019_06407',
|
|
|
|
'CodeInd_1': '501',
|
|
|
|
'AnneeInd_1': '2019',
|
|
|
|
'ValInd_1': 'N',
|
|
|
|
'IndAide': 'Non',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_delete_indana_indicator(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('DossierIndicateur.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('DossierIndicateurSuppressionResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
payload = {'CodeDossier': '2019_06407', 'CodeInd_1': '501', 'AnneeInd_1': '2019'}
|
|
|
|
resp = app.post_json('/astregs/test/delete-indana-indicator', params=payload)
|
|
|
|
assert resp.json == {
|
|
|
|
'err': 0,
|
|
|
|
'data': {
|
|
|
|
'CodeDossier': '2019_06407',
|
|
|
|
'CodeInd_1': '501',
|
|
|
|
'AnneeInd_1': '2019',
|
|
|
|
'ValInd_1': 'N',
|
|
|
|
'IndAide': 'Non',
|
|
|
|
},
|
|
|
|
}
|
2020-05-20 00:35:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_create_tiers_rib(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('TiersRib.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('TiersRibCreationResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
payload = {
|
|
|
|
'CleIban': '76',
|
|
|
|
'CodeBic': 'CODEBIC',
|
|
|
|
'CodeDevise': 'EUR',
|
|
|
|
'CodeIso2Pays': 'FR',
|
|
|
|
'CodePaiement': '3',
|
|
|
|
'CodeStatut': 'PROPOSE',
|
|
|
|
'CodeTiers': '487464',
|
|
|
|
'LibelleCompteEtranger': 'LABEL',
|
|
|
|
'LibelleCourt': 'Test',
|
|
|
|
'LibellePays': 'FR',
|
2021-01-07 18:46:25 +01:00
|
|
|
'NumeroIban': 'FR76AABBCCDDEEFFGGHHIIJJKKLLM',
|
|
|
|
'CodeDomiciliation': '1',
|
2020-05-20 00:35:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resp = app.post_json('/astregs/test/create-tiers-rib', params=payload)
|
|
|
|
assert resp.json['err'] == 0
|
|
|
|
assert resp.json['data']
|
|
|
|
data = resp.json['data']
|
|
|
|
|
|
|
|
assert data['IdRib'] == '621410'
|
|
|
|
assert data['CodeDomiciliation'] == '5'
|
|
|
|
assert data['LibelleGuichet'] == 'GUICHET'
|
|
|
|
assert data['NumeroIban'] == 'FR76 AA BB CC DD EE FF GG HH II JJ KK LLM'
|
|
|
|
assert data['CompteEtranger'] == 'AABBCCDDEEFFGGHHIIJJKKLLM'
|
|
|
|
assert data['LibelleDevise'] == 'Euros'
|
|
|
|
assert data['LibellePays'] == 'France'
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_get_tiers_rib(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('TiersRib.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('TiersRibChargementResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
params = {'CodeTiers': '487464', 'IdRib': '621407'}
|
|
|
|
|
|
|
|
resp = app.get('/astregs/test/get-tiers-rib', params=params)
|
|
|
|
assert resp.json['err'] == 0
|
|
|
|
assert resp.json['data']
|
|
|
|
data = resp.json['data']
|
|
|
|
|
|
|
|
assert data['IdRib'] == '621407'
|
|
|
|
assert data['LibelleCourt'] == 'Test'
|
|
|
|
assert data['CodeDomiciliation'] == '2'
|
|
|
|
assert data['CodeBic'] == 'BIC'
|
|
|
|
assert data['LibelleGuichet'] == 'GUICHET'
|
|
|
|
assert data['NumeroIban'] == 'FR76 AA BB CC DD EE FF GG HH II JJ KK LLM'
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_update_tiers_rib(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('TiersRib.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('TiersRibModificationResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
payload = {
|
|
|
|
'CleIban': '76',
|
|
|
|
'CodeBic': 'CODEBIC',
|
|
|
|
'CodeDevise': 'EUR',
|
|
|
|
'CodeIso2Pays': 'FR',
|
|
|
|
'CodePaiement': '3',
|
|
|
|
'CodeStatut': 'PROPOSE',
|
|
|
|
'CodeTiers': '487464',
|
2021-01-07 18:46:25 +01:00
|
|
|
'CodeDomiciliation': '1',
|
2020-05-20 00:35:06 +02:00
|
|
|
'LibelleCompteEtranger': 'LABEL',
|
|
|
|
'LibelleCourt': 'New Test',
|
|
|
|
'LibellePays': 'FR',
|
|
|
|
'NumeroIban': 'FR76AABBCCDDEEFFGGHHIIJJKKLLM',
|
|
|
|
}
|
|
|
|
|
|
|
|
qs = urlencode({'CodeTiers': '487464', 'IdRib': '621412'})
|
|
|
|
|
|
|
|
resp = app.post_json('/astregs/test/update-tiers-rib?%s' % qs, params=payload)
|
|
|
|
assert resp.json['err'] == 0
|
|
|
|
assert resp.json['data']
|
|
|
|
data = resp.json['data']
|
|
|
|
|
|
|
|
assert data['LibelleCourt'] == 'New Test'
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_delete_tiers_rib(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('TiersRib.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('TiersRibSuppressionResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
|
|
|
|
params = {'CodeTiers': '487464', 'IdRib': '621407'}
|
|
|
|
|
|
|
|
resp = app.get('/astregs/test/delete-tiers-rib', params=params)
|
|
|
|
assert resp.json['err'] == 0
|
|
|
|
assert resp.json['data']
|
|
|
|
data = resp.json['data']
|
|
|
|
|
|
|
|
assert data['IdRib'] is None
|
|
|
|
assert data['CleRib'] is None
|
|
|
|
assert data['CodeBic'] is None
|
|
|
|
assert data['CleIban'] is None
|
2020-08-25 14:09:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_search_tiers_by_rib(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('RechercheTiers.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('RechercheTiersByRibResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
params = {'banque': '30001', 'guichet': '00794', 'numero_compte': '12345678901', 'cle': '85'}
|
|
|
|
|
|
|
|
resp = app.get('/astregs/test/find-tiers-by-rib', params=params)
|
|
|
|
assert resp.json['err'] == 0
|
|
|
|
assert len(resp.json['data']) == 2
|
2020-09-04 10:44:48 +02:00
|
|
|
for item in resp.json['data']:
|
|
|
|
assert 'id' in item
|
|
|
|
assert 'text' in item
|
2020-11-23 17:19:58 +01:00
|
|
|
assert '487464' in item['text'] or '144984' in item['text']
|
2020-09-04 10:44:48 +02:00
|
|
|
|
2020-09-04 10:32:09 +02:00
|
|
|
|
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_search_tiers_by_rib_no_result(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('RechercheTiers.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('RechercheTiersByRibEmptyResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
params = {'banque': '30001', 'guichet': '00794', 'numero_compte': '12345678901', 'cle': '85'}
|
|
|
|
|
|
|
|
resp = app.get('/astregs/test/find-tiers-by-rib', params=params)
|
|
|
|
assert resp.json['err'] == 0
|
|
|
|
assert len(resp.json['data']) == 0
|
2022-02-03 16:30:20 +01:00
|
|
|
|
|
|
|
|
2022-06-01 15:48:12 +02:00
|
|
|
@mock.patch('passerelle.utils.Request.get')
|
|
|
|
@mock.patch('passerelle.utils.Request.post')
|
|
|
|
def test_get_dossier(mocked_post, mocked_get, connector, app):
|
|
|
|
mocked_get.return_value = mock.Mock(content=get_xml_file('Dossier.wsdl'))
|
|
|
|
mocked_post.return_value = mock.Mock(
|
|
|
|
content=get_xml_file('DossierResponse.xml'),
|
|
|
|
headers={'Content-Type': 'text/xml'},
|
|
|
|
status_code=200,
|
|
|
|
)
|
|
|
|
params = {'CodeDossier': '2021-1234'}
|
|
|
|
|
|
|
|
resp = app.get('/astregs/test/get-dossier', params=params)
|
|
|
|
assert resp.json['err'] == 0
|
|
|
|
assert resp.json['data']
|
|
|
|
data = resp.json['data']
|
|
|
|
assert data['Libelle'] == 'Libelle'
|
|
|
|
assert data['LibelleCourt'] == 'Libelle court'
|
|
|
|
assert data['CodeStatut'] == 'VOT'
|
|
|
|
|
|
|
|
|
2022-02-03 16:30:20 +01:00
|
|
|
@mock.patch('passerelle.apps.astregs.models.serialize_object')
|
|
|
|
def test_context_overloading(mocked_serialize_object, connector, app, monkeypatch):
|
|
|
|
mock_operation_result = mock.Mock(liste=False, EncodeKeyContact=False)
|
|
|
|
mock_operation = mock.Mock(return_value=mock_operation_result)
|
|
|
|
|
2022-03-18 14:24:29 +01:00
|
|
|
class MockService:
|
2022-02-03 16:30:20 +01:00
|
|
|
def __getattr__(self, name):
|
|
|
|
return mock_operation
|
|
|
|
|
|
|
|
def mock_get_client(*args, **kwargs):
|
|
|
|
return mock.Mock(service=MockService())
|
|
|
|
|
|
|
|
monkeypatch.setattr(AstreGS, 'get_client', mock_get_client)
|
|
|
|
expected_context = {'Organisme': 'foo', 'Budget': 'bar', 'Exercice': 'baz'}
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
app.get(
|
|
|
|
'/astregs/test/associations',
|
|
|
|
params={'siren': '50043390900014', 'organism': 'foo', 'budget': 'bar', 'exercice': 'baz'},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.kwargs['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
|
|
|
|
# do it a second time on the same endpoints without context parameters
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
app.get('/astregs/test/associations', params={'siren': '50043390900014'})
|
|
|
|
assert mock_operation.call_args.kwargs['Contexte'] == {
|
|
|
|
'Organisme': 'CG06',
|
|
|
|
'Budget': '01',
|
|
|
|
'Exercice': '2019',
|
|
|
|
}
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
app.get(
|
|
|
|
'/astregs/test/check-association-by-siret',
|
|
|
|
params={'siret': '50043390900014', 'organism': 'foo', 'budget': 'bar', 'exercice': 'baz'},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.kwargs['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
app.get(
|
|
|
|
'/astregs/test/get-association-link-means',
|
|
|
|
params={'association_id': '1', 'NameID': '1', 'organism': 'foo', 'budget': 'bar', 'exercice': 'baz'},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
link = Link.objects.create(name_id='1', association_id='1', resource=connector)
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.get(
|
|
|
|
'/astregs/test/get-association-by-id',
|
|
|
|
params={'association_id': '1', 'NameID': '1', 'organism': 'foo', 'budget': 'bar', 'exercice': 'baz'},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
link.delete()
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.post_json(
|
|
|
|
'/astregs/test/create-association',
|
|
|
|
params={
|
|
|
|
'CodeFamille': '51',
|
|
|
|
'CatTiers': '42',
|
|
|
|
'EncodeKeyContact': '4242',
|
|
|
|
'Sigle': 'EO',
|
|
|
|
'NomEnregistrement': 'My association',
|
|
|
|
'Organisme': 'CG06',
|
|
|
|
'NumeroSiret': '112233445',
|
|
|
|
'NumeroSiretFin': '00024',
|
|
|
|
'StatutTiers': 'PROPOSE',
|
|
|
|
'Type': '*',
|
|
|
|
'AdresseTitre': 'AdressePrincipale',
|
|
|
|
'AdresseLibelleRue': '169, rue du Château',
|
|
|
|
'Financier': 'true',
|
|
|
|
'AdresseIsAdresseDeFacturation': 'false',
|
|
|
|
'AdresseIsAdresseDeCommande': 'false',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.get(
|
|
|
|
'/astregs/test/get-contact',
|
|
|
|
params={'contact_id': '1', 'organism': 'foo', 'budget': 'bar', 'exercice': 'baz'},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.post_json(
|
|
|
|
'/astregs/test/create-contact',
|
|
|
|
params={
|
|
|
|
'AdresseDestinataire': '169 rue du Ch\xc3\xa2teau',
|
|
|
|
'Ville': 'Nice',
|
|
|
|
'CodeContact': 'AS207002',
|
|
|
|
'Commentaire': 'Contact creation',
|
|
|
|
'country_code': 'FR',
|
|
|
|
'AdresseMail': 'foo@example.com',
|
|
|
|
'Prenom': 'Foo',
|
|
|
|
'Nom': 'Bar',
|
|
|
|
'TelephoneMobile': '0607080900',
|
|
|
|
'TelephoneBureau': '0102030405',
|
|
|
|
'CodeTitreCivilite': '035',
|
|
|
|
'PageWeb': 'http://example.com',
|
|
|
|
'CodePostal': '06000',
|
|
|
|
'CodeFonction': '01',
|
|
|
|
'EncodeKeyStatut': 'VALIDE',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.get(
|
|
|
|
'/astregs/test/delete-contact',
|
|
|
|
params={'contact_id': '1', 'organism': 'foo', 'budget': 'bar', 'exercice': 'baz'},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.post_json(
|
|
|
|
'/astregs/test/create-document',
|
|
|
|
params={
|
|
|
|
'Sujet': 'Test',
|
|
|
|
'Entite': 'COMMANDE',
|
|
|
|
'CodType': 'COMMANDE',
|
|
|
|
'Type': 'Type label',
|
|
|
|
'hdnCodeTrt': 'UPDATE',
|
|
|
|
'EncodeKeyEntite': '|25901|',
|
|
|
|
'CodeDomaine': 'GF',
|
|
|
|
'CodDom': 'GF',
|
|
|
|
'Metadonnees': '|Organisme *CG06|Code Tiers *1|',
|
|
|
|
'document': {
|
|
|
|
'filename': 'test.pdf',
|
|
|
|
'content_type': 'application/pdf',
|
|
|
|
'content': 'base64encodedcontent',
|
|
|
|
},
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.post_json(
|
|
|
|
'/astregs/test/create-grant-demand',
|
|
|
|
params={
|
|
|
|
'Libelle': 'test grant demand',
|
|
|
|
'LibelleCourt': 'test',
|
|
|
|
'ModGestion': '1',
|
|
|
|
'TypeAide': 'F',
|
|
|
|
'Sens': 'D',
|
|
|
|
'CodeTiersDem': '487473',
|
|
|
|
'CodeServiceGestionnaire': 'SGG',
|
|
|
|
'CodeAide': '030105',
|
|
|
|
'CodeServiceUtilisateur': '030105',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.post_json(
|
|
|
|
'/astregs/test/create-indana-indicator',
|
|
|
|
params={
|
|
|
|
'CodeDossier': '2019_06407',
|
|
|
|
'CodeInd_1': '501',
|
|
|
|
'AnneeInd_1': '2019',
|
|
|
|
'ValInd_1': 'O',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.post_json(
|
|
|
|
'/astregs/test/update-indana-indicator',
|
|
|
|
params={
|
|
|
|
'CodeDossier': '2019_06407',
|
|
|
|
'CodeInd_1': '501',
|
|
|
|
'AnneeInd_1': '2019',
|
|
|
|
'ValInd_1': 'N',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.post_json(
|
|
|
|
'/astregs/test/delete-indana-indicator',
|
|
|
|
params={
|
|
|
|
'CodeDossier': '2019_06407',
|
|
|
|
'CodeInd_1': '501',
|
|
|
|
'AnneeInd_1': '2019',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.post_json(
|
|
|
|
'/astregs/test/create-tiers-rib',
|
|
|
|
params={
|
|
|
|
'CleIban': '76',
|
|
|
|
'CodeBic': 'CODEBIC',
|
|
|
|
'CodeDevise': 'EUR',
|
|
|
|
'CodeIso2Pays': 'FR',
|
|
|
|
'CodePaiement': '3',
|
|
|
|
'CodeStatut': 'PROPOSE',
|
|
|
|
'CodeTiers': '487464',
|
|
|
|
'LibelleCompteEtranger': 'LABEL',
|
|
|
|
'LibelleCourt': 'Test',
|
|
|
|
'LibellePays': 'FR',
|
|
|
|
'NumeroIban': 'FR76AABBCCDDEEFFGGHHIIJJKKLLM',
|
|
|
|
'CodeDomiciliation': '1',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.get(
|
|
|
|
'/astregs/test/get-tiers-rib',
|
|
|
|
params={
|
|
|
|
'CodeTiers': '487464',
|
|
|
|
'IdRib': '621407',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
qs = urlencode({'CodeTiers': '487464', 'IdRib': '621412'})
|
|
|
|
app.post_json(
|
|
|
|
'/astregs/test/update-tiers-rib?%s' % qs,
|
|
|
|
params={
|
|
|
|
'CleIban': '76',
|
|
|
|
'CodeBic': 'CODEBIC',
|
|
|
|
'CodeDevise': 'EUR',
|
|
|
|
'CodeIso2Pays': 'FR',
|
|
|
|
'CodePaiement': '3',
|
|
|
|
'CodeStatut': 'PROPOSE',
|
|
|
|
'CodeTiers': '487464',
|
|
|
|
'CodeDomiciliation': '1',
|
|
|
|
'LibelleCompteEtranger': 'LABEL',
|
|
|
|
'LibelleCourt': 'New Test',
|
|
|
|
'LibellePays': 'FR',
|
|
|
|
'NumeroIban': 'FR76AABBCCDDEEFFGGHHIIJJKKLLM',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.get(
|
|
|
|
'/astregs/test/delete-tiers-rib',
|
|
|
|
params={
|
|
|
|
'CodeTiers': '487464',
|
|
|
|
'IdRib': '621407',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.args[0]['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.get(
|
|
|
|
'/astregs/test/find-tiers-by-rib',
|
|
|
|
params={
|
|
|
|
'banque': '30001',
|
|
|
|
'guichet': '00794',
|
|
|
|
'numero_compte': '12345678901',
|
|
|
|
'cle': '85',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.kwargs['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.get(
|
|
|
|
'/astregs/test/link',
|
|
|
|
params={
|
|
|
|
'association_id': '42',
|
|
|
|
'NameID': 'user_name_id',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.kwargs['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|
|
|
|
|
|
|
|
assert not mock_operation.call_args
|
|
|
|
mocked_serialize_object.configure_mock(return_value=[])
|
|
|
|
app.get(
|
|
|
|
'/astregs/test/links',
|
|
|
|
params={
|
|
|
|
'NameID': 'user_name_id',
|
|
|
|
'organism': 'foo',
|
|
|
|
'budget': 'bar',
|
|
|
|
'exercice': 'baz',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
assert mock_operation.call_args.kwargs['Contexte'] == expected_context
|
|
|
|
mock_operation.reset_mock()
|
|
|
|
mocked_serialize_object.reset_mock()
|