authenticated_client = <rest_framework.test.APIClient object at 0x7fb007d53860>
deposit_collection = <DepositCollection: {'id': 11, 'name': 'test'}>
deposit_another_collection = <DepositCollection: {'id': 12, 'name': 'another-collection'}>
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_origin0/tmp9yb81gjv', 'length': 128, 'md5sum': '7a8db9439980b853e0410b722e87b5bc', ...}
deposit_user = <DepositClient: {'id': 10, 'collections': [11], 'username': 'test', 'domain': 'archives-ouvertes.fr/', 'provider_url': 'https://hal-test.archives-ouvertes.fr/'}>
deposit_another_user = <DepositClient: {'id': 11, 'collections': [12], 'username': 'test2', 'domain': 'archives-ouvertes.example/', 'provider_url': 'https://hal-test.archives-ouvertes.example/'}>
def test_add_deposit_add_to_origin_conflict(
authenticated_client,
deposit_collection,
deposit_another_collection,
atom_dataset,
sample_archive,
deposit_user,
deposit_another_user,
):
"""Posting a deposit with an <swh:add_to_origin> referencing an origin
owned by a different client raises an error
"""
external_id = "foobar"
origin_url = deposit_another_user.provider_url + external_id
# create a deposit for that other user, with the same slug
internal_create_deposit(
deposit_another_user,
deposit_another_collection,
external_id,
DEPOSIT_STATUS_LOAD_SUCCESS,
)
# 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
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:88: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Feb 23 2022, 3:56 PM