api_client = <rest_framework.test.APIClient object at 0x7f45e41f0550>
unknown_content = {'blake2s256': 'd3ae7415cd93c1afba52c4d6f60244d09d24b63032175bbfecaa5f114c985a7e', 'sha1': 'abe8f3170779c2f9a709b31b8f...31f52aa121d992a5600e2ba3fd11a0033628f78', 'sha256': 'f8d6338eb2a4429f2a0caea44ed8a4deb3c98c0a9877bf37884299af63c79484'}
unknown_directory = 'ff8888080e275fe0945b14ca8af97106e2378f8b'
unknown_release = '339a179eef87a2a2fc50df55caf72656ad11f343'
unknown_revision = 'c5dc4be7637eaad2a902b6bdfb05c9124a237bd0'
unknown_snapshot = '20d203be45d9bb752486f5f6fa9e9e0dd57c1882'
def test_swhid_resolve_not_found(
api_client,
unknown_content,
unknown_directory,
unknown_release,
unknown_revision,
unknown_snapshot,
):
for obj_type, obj_id in (
(ObjectType.CONTENT, unknown_content["sha1_git"]),
(ObjectType.DIRECTORY, unknown_directory),
(ObjectType.RELEASE, unknown_release),
(ObjectType.REVISION, unknown_revision),
(ObjectType.SNAPSHOT, unknown_snapshot),
):
swhid = gen_swhid(obj_type, obj_id)
url = reverse("api-1-resolve-swhid", url_args={"swhid": swhid})
> check_api_get_responses(api_client, url, status_code=404)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/api/views/test_identifiers.py:88:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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 0x7f45e41f0550>
url = '/api/1/resolve/swh:1:cnt:431f52aa121d992a5600e2ba3fd11a0033628f78/'
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