authenticated_client = <rest_framework.test.APIClient object at 0x7fc00a403ac8>
deposit_collection = <DepositCollection: {'id': 120, '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', ...}
deposit_user = <DepositClient: {'id': 119, 'collections': [120], 'username': 'test', 'domain': 'archives-ouvertes.fr/', 'provider_url': 'https://hal-test.archives-ouvertes.fr/'}>
def test_put_atom_with_create_origin_and_reference(
authenticated_client, deposit_collection, atom_dataset, deposit_user
):
"""<swh:reference> and <swh:create_origin> are mutually exclusive
"""
external_id = "foobar"
origin_url = deposit_user.provider_url + external_id
url = reverse(COL_IRI, args=[deposit_collection.name])
response = authenticated_client.post(
url,
content_type="application/atom+xml;type=entry",
data=atom_dataset["entry-data0"] % origin_url,
HTTP_IN_PROGRESS="true",
)
assert response.status_code == status.HTTP_201_CREATED
response_content = parse_xml(BytesIO(response.content))
for link in response_content["atom:link"]:
if link["@rel"] == "edit":
edit_iri = link["@href"]
break
else:
assert False, response_content
# when
response = authenticated_client.put(
edit_iri,
content_type="application/atom+xml;type=entry",
> data=atom_dataset["entry-data-with-origin-reference"].format(url=origin_url),
# + headers
HTTP_IN_PROGRESS="false",
)
E KeyError: 'entry-data-with-origin-reference'
.tox/py3/lib/python3.7/site-packages/swh/deposit/tests/api/test_deposit_update.py:878: KeyError
TEST RESULT
TEST RESULT
- Run At
- Nov 27 2020, 2:51 PM