plone_restapi: use ok webservice to get service status (#77695)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
be4a65b6be
commit
816da0f6b6
|
@ -201,7 +201,8 @@ class PloneRestApi(BaseResource, HTTPResource):
|
||||||
"""
|
"""
|
||||||
Raise an exception if something goes wrong.
|
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(
|
def call_search(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -18,7 +18,7 @@ import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from requests.exceptions import ConnectionError
|
from requests.exceptions import ConnectionError, HTTPError
|
||||||
|
|
||||||
import tests.utils
|
import tests.utils
|
||||||
from passerelle.apps.plone_restapi.models import PloneRestApi, Query
|
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):
|
def test_check_status(app, connector):
|
||||||
url = connector.service_url + '/@types'
|
url = connector.service_url + '/ok'
|
||||||
with tests.utils.mock_url(url=connector.token_ws_url, response=TOKEN_RESPONSE):
|
with tests.utils.mock_url(url=url, response='OK'):
|
||||||
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={}):
|
|
||||||
connector.check_status()
|
connector.check_status()
|
||||||
|
|
||||||
# plone not responding
|
# plone not responding
|
||||||
with tests.utils.mock_url(url=url, response={}, status_code=503):
|
with tests.utils.mock_url(url=url, response={}, status_code=500):
|
||||||
with pytest.raises(APIError):
|
with pytest.raises(HTTPError):
|
||||||
|
connector.check_status()
|
||||||
|
with tests.utils.mock_url(url=url, exception=ConnectionError('plop')):
|
||||||
|
with pytest.raises(ConnectionError):
|
||||||
connector.check_status()
|
connector.check_status()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue