api_client = <rest_framework.test.APIClient object at 0x7f0d5d8bb2e8>
keycloak_oidc = <swh.auth.pytest_plugin.KeycloackOpenIDConnectMock object at 0x7f0d5dc2d160>
requests_mock = <requests_mock.mocker.Mocker object at 0x7f0d5d257cc0>
def test_graph_text_plain_response(api_client, keycloak_oidc, requests_mock):
_authenticate_graph_user(api_client, keycloak_oidc)
graph_query = "leaves/swh:1:dir:432d1b21c1256f7408a07c577b6974bbdbcc1323"
response_text = textwrap.dedent(
"""\
swh:1:cnt:1d3dace0a825b0535c37c53ed669ef817e9c1b47
swh:1:cnt:6d5b280f4e33589ae967a7912a587dd5cb8dedaa
swh:1:cnt:91bef238bf01356a550d416d14bb464c576ac6f4
swh:1:cnt:58a8b925a463b87d49639fda282b8f836546e396
swh:1:cnt:fd32ee0a87e16ccc853dfbeb7018674f9ce008c0
swh:1:cnt:ab7c39871872589a4fc9e249ebc927fb1042c90d
swh:1:cnt:93073c02bf3869845977527de16af4d54765838d
swh:1:cnt:4251f795b52c54c447a97c9fe904d8b1f993b1e0
swh:1:cnt:c6e7055424332006d07876ffeba684e7e284b383
swh:1:cnt:8459d8867dc3b15ef7ae9683e21cccc9ab2ec887
swh:1:cnt:5f9981d52202815aa947f85b9dfa191b66f51138
swh:1:cnt:00a685ec51bcdf398c15d588ecdedb611dbbab4b
swh:1:cnt:e1cf1ea335106a0197a2f92f7804046425a7d3eb
swh:1:cnt:07069b38087f88ec192d2c9aff75a502476fd17d
swh:1:cnt:f045ee845c7f14d903a2c035b2691a7c400c01f0
"""
)
requests_mock.get(
get_config()["graph"]["server_url"] + graph_query,
text=response_text,
headers={"Content-Type": "text/plain", "Transfer-Encoding": "chunked"},
)
url = reverse("api-1-graph", url_args={"graph_query": graph_query})
resp = check_http_get_response(
> api_client, url, status_code=200, content_type="text/plain"
)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/api/views/test_graph.py:98:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:66: in check_http_get_response
content_type=content_type,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = <Response status_code=500, "text/plain">, status_code = 200
content_type = 'text/plain'
def _assert_http_response(
response: HttpResponse, status_code: int, content_type: str
) -> HttpResponse:
if isinstance(response, Response):
drf_response = cast(Response, response)
error_context = (
drf_response.data.pop("traceback")
if isinstance(drf_response.data, dict) and "traceback" in drf_response.data
else drf_response.data
)
elif isinstance(response, StreamingHttpResponse):
error_context = getattr(response, "traceback", response.streaming_content)
else:
error_context = getattr(response, "traceback", response.content)
> assert response.status_code == status_code, error_context
E AssertionError: Traceback (most recent call last):
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/rest_framework/views.py", line 506, in dispatch
E response = handler(request, *args, **kwargs)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/rest_framework/decorators.py", line 50, in handler
E return func(*args, **kwargs)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/web/api/apiurls.py", line 96, in api_view_f
E response = f(request, **kwargs)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/web/api/views/graph.py", line 141, in api_graph_proxy
E response = requests.get(graph_query_url, stream=True)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/requests/api.py", line 76, in get
E return request('get', url, params=params, **kwargs)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/requests/api.py", line 61, in request
E return session.request(method=method, url=url, **kwargs)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/requests/sessions.py", line 542, in request
E resp = self.send(prep, **send_kwargs)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/requests_mock/mocker.py", line 144, in _fake_send
E return _original_send(session, request, **kwargs)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/requests/sessions.py", line 655, in send
E r = adapter.send(request, **kwargs)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/requests_mock/adapter.py", line 260, in send
E raise exceptions.NoMockAddress(request)
E requests_mock.exceptions.NoMockAddress: No mock address: GET http://graph.internal.softwareheritage.org:5009/graph/leaves/swh:1:dir:432d1b21c1256f7408a07c577b6974bbdbcc1323
E
E assert 500 == 200
E +500
E -200
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:32: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Apr 28 2021, 12:26 PM