authenticated_client = <rest_framework.test.APIClient object at 0x7f8bcd474be0>
deposit_collection = <DepositCollection: {'id': 26, 'name': 'test'}>
sample_archive = {'data': b'PK\x03\x04\x14\x00\x00\x00\x00\x00\x97\\\xbcP\xcba\xb4c\x14\x00\x00\x00\x14\x00\x00\x00\x05\x00\x00\x00file...ytest-0/test_post_deposit_binary_and_p0/tmppopa8o1z', 'length': 128, 'md5sum': 'a1144f40c0ef1281bbbe7a297028e4e1', ...}
tmp_path = '/tmp/pytest-of-jenkins/pytest-0/test_post_deposit_binary_and_p0'
def test_post_deposit_binary_and_post_to_add_another_archive(
authenticated_client, deposit_collection, sample_archive, tmp_path
):
"""Updating a deposit should return a 201 with receipt
"""
tmp_path = str(tmp_path)
url = reverse(COL_IRI, args=[deposit_collection.name])
external_id = "some-external-id-1"
# when
response = authenticated_client.post(
url,
content_type="application/zip", # as zip
data=sample_archive["data"],
# + headers
CONTENT_LENGTH=sample_archive["length"],
HTTP_SLUG=external_id,
HTTP_CONTENT_MD5=sample_archive["md5sum"],
HTTP_PACKAGING="http://purl.org/net/sword/package/SimpleZip",
HTTP_IN_PROGRESS="true",
HTTP_CONTENT_DISPOSITION="attachment; filename=%s" % (sample_archive["name"],),
)
# then
assert response.status_code == status.HTTP_201_CREATED
response_content = parse_xml(BytesIO(response.content))
deposit_id = response_content["deposit_id"]
deposit = Deposit.objects.get(pk=deposit_id)
assert deposit.status == "partial"
assert deposit.external_id == external_id
assert deposit.collection == deposit_collection
assert deposit.swh_id is None
deposit_request = DepositRequest.objects.get(deposit=deposit)
assert deposit_request.deposit == deposit
assert deposit_request.type == "archive"
> check_archive(sample_archive["name"], deposit_request.archive.name)
.tox/py3/lib/python3.7/site-packages/swh/deposit/tests/api/test_deposit_binary.py:369:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
archive_name = 'archive1.zip', archive_name_to_check = 'client_25/archive1.zip'
def check_archive(archive_name: str, archive_name_to_check: str):
"""Helper function to ensure archive_name is present within the
archive_name_to_check.
Raises:
AssertionError if archive_name is not present within
archive_name_to_check
"""
pattern = re.compile(".*/.*_%s" % archive_name)
> assert pattern.match(archive_name_to_check) is not None
E AssertionError: assert None is not None
E + where None = <built-in method match of re.Pattern object at 0x7f8bcd73e378>('client_25/archive1.zip')
E + where <built-in method match of re.Pattern object at 0x7f8bcd73e378> = re.compile('.*/.*_archive1.zip').match
.tox/py3/lib/python3.7/site-packages/swh/deposit/tests/common.py:137: AssertionError
TEST RESULT
TEST RESULT
- Run At
- May 28 2020, 1:37 PM