client = <django.test.client.Client object at 0x7fdbe2f96780>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fdbe2f96f60>
def test_content_too_large(client, mocker):
mock_request_content = mocker.patch("swh.web.browse.views.content.request_content")
stub_content_too_large_data = {
"checksums": {
"sha1": "8624bcdae55baeef00cd11d5dfcfa60f68710a02",
"sha1_git": "94a9ed024d3859793618152ea559a168bbcbb5e2",
"sha256": (
"8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b16" "5a1dcd80c7c545eb65b903"
),
"blake2s256": (
"38702b7168c7785bfe748b51b45d9856070ba90" "f9dc6d90f2ea75d4356411ffe"
),
},
"length": 30000000,
"raw_data": None,
"mimetype": "text/plain",
"encoding": "us-ascii",
"language": "not detected",
"licenses": "GPL",
"error_code": 200,
"error_message": "",
"error_description": "",
}
content_sha1 = stub_content_too_large_data["checksums"]["sha1"]
mock_request_content.return_value = stub_content_too_large_data
url = reverse("browse-content", url_args={"query_string": content_sha1})
url_raw = reverse("browse-content-raw", url_args={"query_string": content_sha1})
resp = check_html_get_response(
> client, url, status_code=200, template_used="browse/content.html"
)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/browse/views/test_content.py:378:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:205: in check_html_get_response
client, url, status_code, content_type="text/html"
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:66: in check_http_get_response
content_type=content_type,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = <HttpResponse status_code=500, "text/html; charset=utf-8">
status_code = 200, content_type = 'text/html'
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/django/core/handlers/base.py", line 113, in _get_response
E response = wrapped_callback(request, *callback_args, **callback_kwargs)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/web/browse/views/content.py", line 401, in content_display
E status=error_info["status_code"],
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/shortcuts.py", line 36, in render
E content = loader.render_to_string(template_name, context, request, using=using)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/loader.py", line 62, in render_to_string
E return template.render(context, request)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/backends/django.py", line 61, in render
E return self.template.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 171, in render
E return self._render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
E return self.nodelist.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 937, in render
E bit = node.render_annotated(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
E return self.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render
E return compiled_parent._render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
E return self.nodelist.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 937, in render
E bit = node.render_annotated(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
E return self.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render
E return compiled_parent._render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
E return self.nodelist.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 937, in render
E bit = node.render_annotated(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
E return self.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render
E return compiled_parent._render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
E return self.nodelist.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 937, in render
E bit = node.render_annotated(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
E return self.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/loader_tags.py", line 62, in render
E result = block.nodelist.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 937, in render
E bit = node.render_annotated(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
E return self.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/loader_tags.py", line 62, in render
E result = block.nodelist.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 937, in render
E bit = node.render_annotated(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
E return self.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/loader_tags.py", line 62, in render
E result = block.nodelist.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 937, in render
E bit = node.render_annotated(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
E return self.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/loader_tags.py", line 188, in render
E return template.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 173, in render
E return self._render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
E return self.nodelist.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 937, in render
E bit = node.render_annotated(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
E return self.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/loader_tags.py", line 188, in render
E return template.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 173, in render
E return self._render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
E return self.nodelist.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 937, in render
E bit = node.render_annotated(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
E return self.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/defaulttags.py", line 309, in render
E return nodelist.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 937, in render
E bit = node.render_annotated(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
E return self.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/defaulttags.py", line 209, in render
E nodelist.append(node.render_annotated(context))
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
E return self.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/defaulttags.py", line 309, in render
E return nodelist.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 937, in render
E bit = node.render_annotated(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
E return self.render(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 987, in render
E output = self.filter_expression.resolve(context)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/django/template/base.py", line 698, in resolve
E new_obj = func(obj, *arg_vals)
E File "/var/lib/jenkins/workspace/DWAPPS/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/web/common/swh_templatetags.py", line 124, in key_value
E return dict[key]
E KeyError: <ObjectType.CONTENT: 'cnt'>
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
- Mar 3 2021, 10:02 AM