toulouse_maelis: cache soap_client for 5 minutes (#81418)
gitea/passerelle/pipeline/head This commit looks good Details

This commit is contained in:
Benjamin Dauvergne 2023-09-20 18:05:12 +02:00
parent faf3e4692e
commit a192a953b9
2 changed files with 8 additions and 2 deletions

View File

@ -95,6 +95,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
category = 'Connecteurs métiers'
_category_ordering = ['Famille', 'Activités']
soap_client_cache_timeout = 300 # 5 minutes of cache for zeep.Client
class Meta:
verbose_name = 'Toulouse Maelis'

View File

@ -80,7 +80,7 @@ def get_endpoint(name):
@pytest.fixture
def requests_mock():
return responses.RequestsMock()
return responses.RequestsMock(assert_all_requests_are_fired=False)
@pytest.fixture()
@ -132,11 +132,12 @@ def site_service(requests_mock):
@pytest.fixture()
def ape_service():
def ape_service(requests_mock):
with ResponsesSoap(
wsdl_url='https://example.org/ApeService?wsdl',
wsdl_content=get_wsdl_file('ApeService.wsdl'),
settings=Settings(strict=False, xsd_ignore_sequence_order=True),
requests_mock=requests_mock,
)() as mock:
yield mock
@ -343,6 +344,7 @@ def test_manager_update_referentials(admin_user, app, con):
assert job.method_name == 'update_referentials'
@mock.patch('passerelle.contrib.toulouse_maelis.models.ToulouseMaelis.soap_client_cache_timeout', 0)
@mock.patch('passerelle.utils.Request.get')
def test_call_with_wrong_wsdl_url(mocked_get, con):
mocked_get.side_effect = CONNECTION_ERROR
@ -356,6 +358,7 @@ def test_call_with_wrong_wsdl_url(mocked_get, con):
assert e.value.url == 'https://example.org/FamilyService?wsdl'
@mock.patch('passerelle.contrib.toulouse_maelis.models.ToulouseMaelis.soap_client_cache_timeout', 0)
@mock.patch('passerelle.utils.Request.get')
def test_call_with_wrong_wsdl_content(mocked_get, con):
mocked_get.return_value = TOMCAT_ERROR
@ -363,6 +366,7 @@ def test_call_with_wrong_wsdl_content(mocked_get, con):
con.call('Family', 'isWSRunning')
@mock.patch('passerelle.contrib.toulouse_maelis.models.ToulouseMaelis.soap_client_cache_timeout', 0)
@mock.patch('passerelle.utils.Request.get')
def test_call_with_wrong_wsdl_content_bis(mocked_get, con, app):
mocked_get.return_value = TOMCAT_ERROR
@ -373,6 +377,7 @@ def test_call_with_wrong_wsdl_content_bis(mocked_get, con, app):
assert "'NoneType' object has no attribute 'getroottree'" in resp.json['err_desc']
@mock.patch('passerelle.contrib.toulouse_maelis.models.ToulouseMaelis.soap_client_cache_timeout', 0)
@mock.patch('passerelle.utils.Request.get')
@mock.patch('passerelle.utils.Request.post')
def test_call_with_wrong_soap_content(mocked_post, mocked_get, con):