Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_deposit_private_read_archive.py
| Show All 34 Lines | ): | ||||
| """ | """ | ||||
| deposit = complete_deposit | deposit = complete_deposit | ||||
| for i, url in enumerate(private_get_raw_url_endpoints(deposit_collection, deposit)): | for i, url in enumerate(private_get_raw_url_endpoints(deposit_collection, deposit)): | ||||
| response = authenticated_client.get(url) | response = authenticated_client.get(url) | ||||
| assert response.status_code == status.HTTP_200_OK | assert response.status_code == status.HTTP_200_OK | ||||
| assert response._headers["content-type"][1] == "application/tar" | assert response["content-type"] == "application/tar" | ||||
| # write the response stream in a temporary archive | # write the response stream in a temporary archive | ||||
| archive_path = join(tmp_path, f"archive_{i}.tar") | archive_path = join(tmp_path, f"archive_{i}.tar") | ||||
| with open(archive_path, "wb") as f: | with open(archive_path, "wb") as f: | ||||
| for chunk in response.streaming_content: | for chunk in response.streaming_content: | ||||
| f.write(chunk) | f.write(chunk) | ||||
| # to check its properties are correct | # to check its properties are correct | ||||
| Show All 28 Lines | response = authenticated_client.post( | ||||
| HTTP_CONTENT_DISPOSITION="attachment; filename=%s" % (archive2["name"],), | HTTP_CONTENT_DISPOSITION="attachment; filename=%s" % (archive2["name"],), | ||||
| ) | ) | ||||
| assert response.status_code == status.HTTP_201_CREATED | assert response.status_code == status.HTTP_201_CREATED | ||||
| for i, url in enumerate(private_get_raw_url_endpoints(deposit_collection, deposit)): | for i, url in enumerate(private_get_raw_url_endpoints(deposit_collection, deposit)): | ||||
| response = authenticated_client.get(url) | response = authenticated_client.get(url) | ||||
| assert response.status_code == status.HTTP_200_OK | assert response.status_code == status.HTTP_200_OK | ||||
| assert response._headers["content-type"][1] == "application/tar" | assert response["content-type"] == "application/tar" | ||||
| # write the response stream in a temporary archive | # write the response stream in a temporary archive | ||||
| archive_path = join(tmp_path, f"archive_{i}.tar") | archive_path = join(tmp_path, f"archive_{i}.tar") | ||||
| with open(archive_path, "wb") as f: | with open(archive_path, "wb") as f: | ||||
| for chunk in response.streaming_content: | for chunk in response.streaming_content: | ||||
| f.write(chunk) | f.write(chunk) | ||||
| # to check its properties are correct | # to check its properties are correct | ||||
| tfile = tarfile.open(archive_path) | tfile = tarfile.open(archive_path) | ||||
| Show All 10 Lines | |||||