authenticated_client = <rest_framework.test.APIClient object at 0x7fb007cda3c8>
deposit_collection = <DepositCollection: {'id': 13, 'name': 'test'}>
atom_dataset = {'codemeta-sample': '<?xml version="1.0"?>\n <entry xmlns="http://www.w3.org/2005/Atom"\n xmlns:d...ntry>\n', 'entry-data-empty-body': '<?xml version="1.0"?>\n<entry xmlns="http://www.w3.org/2005/Atom"></entry>\n', ...}
sample_archive = {'data': b'PK\x03\x04\x14\x00\x00\x00\x00\x00@vWT\xcba\xb4c\x14\x00\x00\x00\x14\x00\x00\x00\x05\x00\x00\x00file1some c...ytest-0/test_add_deposit_add_to_wrong_0/tmpc_zq_mzl', 'length': 128, 'md5sum': 'c618b0b0b89844ffb9d6e00db279ab61', ...}
def test_add_deposit_add_to_wrong_origin(
authenticated_client, deposit_collection, atom_dataset, sample_archive,
):
"""Posting a deposit with an <swh:add_to_origin> referencing an origin
not starting with the provider_url raises an error
"""
origin_url = "http://example.org/foo"
# adding a new deposit with the same external id as a completed deposit
response = post_atom(
authenticated_client,
reverse(COL_IRI, args=[deposit_collection.name]),
data=atom_dataset["entry-data0"] % origin_url,
)
> assert response.status_code == status.HTTP_403_FORBIDDEN, response.content.decode()
E AssertionError: <?xml version="1.0" encoding="utf-8"?>
E <sword:error xmlns="http://www.w3.org/2005/Atom"
E xmlns:sword="http://purl.org/net/sword/terms/">
E <summary>Malformed xml metadata</summary>
E <sword:treatment>processing failed</sword:treatment>
E
E <sword:verboseDescription>
E The xml received is malformed. Please ensure your metadata file is correctly formatted.
E </sword:verboseDescription>
E
E </sword:error>
E
E assert 400 == 403
E +400
E -403
.tox/py3/lib/python3.7/site-packages/swh/deposit/tests/api/test_collection_add_to_origin.py:108: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Feb 23 2022, 3:56 PM