diff --git a/passerelle/apps/plone_restapi/models.py b/passerelle/apps/plone_restapi/models.py index 3a3bfa0c..059e8c31 100644 --- a/passerelle/apps/plone_restapi/models.py +++ b/passerelle/apps/plone_restapi/models.py @@ -201,7 +201,8 @@ class PloneRestApi(BaseResource, HTTPResource): """ Raise an exception if something goes wrong. """ - self.request(path='@types', method='GET') + response = self.requests.get(self.service_url + '/ok') + response.raise_for_status() def call_search( self, diff --git a/tests/test_plone_restapi.py b/tests/test_plone_restapi.py index 12f6d14b..63955a1f 100644 --- a/tests/test_plone_restapi.py +++ b/tests/test_plone_restapi.py @@ -18,7 +18,7 @@ import json import os import pytest -from requests.exceptions import ConnectionError +from requests.exceptions import ConnectionError, HTTPError import tests.utils from passerelle.apps.plone_restapi.models import PloneRestApi, Query @@ -225,31 +225,16 @@ def test_get_token(app, connector): def test_check_status(app, connector): - url = connector.service_url + '/@types' - with tests.utils.mock_url(url=connector.token_ws_url, response=TOKEN_RESPONSE): - with tests.utils.mock_url(url=url, response={}): - connector.check_status() - - # idp not responding - with tests.utils.mock_url(url=connector.token_ws_url, response={}, status_code=503): - with pytest.raises(APIError): - connector.check_status() - - # plone not responding - with tests.utils.mock_url(url=connector.token_ws_url, response=TOKEN_RESPONSE): - with tests.utils.mock_url(url=url, response={}, status_code=503): - with pytest.raises(APIError): - connector.check_status() - - # without idp - connector.token_ws_url = '' - connector.save() - with tests.utils.mock_url(url=url, response={}): + url = connector.service_url + '/ok' + with tests.utils.mock_url(url=url, response='OK'): connector.check_status() # plone not responding - with tests.utils.mock_url(url=url, response={}, status_code=503): - with pytest.raises(APIError): + with tests.utils.mock_url(url=url, response={}, status_code=500): + with pytest.raises(HTTPError): + connector.check_status() + with tests.utils.mock_url(url=url, exception=ConnectionError('plop')): + with pytest.raises(ConnectionError): connector.check_status()