api_client = <rest_framework.test.APIClient object at 0x7f45de11df60>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7f45de20c048>
directory = 'cd19126d815470b28919d64b2a8e6a3e37f900dd'
revision = '1cf33c85d52fc849216a838a7b2a087486ee9bef'
unknown_directory = '8650038ab4c6e2b174fe8e1c0e12d3c53c36d301'
unknown_revision = '4e51fd1343b4fa052bf61156be7ff0952bc760fe'
def test_api_vault_cook_notfound(
api_client, mocker, directory, revision, unknown_directory, unknown_revision
):
mock_vault = mocker.patch("swh.web.common.archive.vault")
mock_vault.cook.side_effect = NotFoundExc("object not found")
mock_vault.fetch.side_effect = NotFoundExc("cooked archive not found")
mock_vault.progress.side_effect = NotFoundExc("cooking request not found")
for bundle_type, swhid in (
("flat", f"swh:1:dir:{directory}"),
("gitfast", f"swh:1:rev:{revision}"),
("git_bare", f"swh:1:rev:{revision}"),
):
swhid = CoreSWHID.from_string(swhid)
url = reverse(
f"api-1-vault-cook-{bundle_type.replace('_', '-')}",
url_args={"swhid": str(swhid)},
)
> rv = check_api_get_responses(api_client, url, status_code=404)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/api/views/test_vault.py:93:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:131: in check_api_get_responses
check_http_get_response(api_client, url, status_code, content_type="text/html")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
client = <rest_framework.test.APIClient object at 0x7f45de11df60>
url = '/api/1/vault/flat/swh:1:dir:cd19126d815470b28919d64b2a8e6a3e37f900dd/'
status_code = 404, content_type = 'text/html', http_origin = None
server_name = None
def check_http_get_response(
client: Client,
url: str,
status_code: int,
content_type: str = "*/*",
http_origin: Optional[str] = None,
server_name: Optional[str] = None,
) -> HttpResponse:
"""Helper function to check HTTP response for a GET request.
Args:
client: Django test client
url: URL to check response
status_code: expected HTTP status code
content_type: expected response content type
http_origin: optional HTTP_ORIGIN header value
Returns:
The HTTP response
"""
actual_response = client.get(
url,
HTTP_ACCEPT=content_type,
HTTP_ORIGIN=http_origin,
SERVER_NAME=server_name if server_name else "testserver",
)
> assert isinstance(actual_response, Response)
E assert False
E + where False = isinstance(<HttpResponse status_code=404, "text/html; charset=utf-8">, Response)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:66: AssertionError
TEST RESULT
TEST RESULT
- Run At
- May 25 2022, 4:46 PM