authenticated_client = <rest_framework.test.APIClient object at 0x7f7cf8484c88>
deposit_collection = <DepositCollection: {'id': 35, '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', ...}
def test_deposit_metadata_invalid(
authenticated_client, deposit_collection, atom_dataset
):
"""Posting invalid swhid reference is bad request returned to client
"""
invalid_swhid = "swh:1:dir :31b5c8cc985d190b5a7ef4878128ebfdc2358f49"
xml_data = atom_dataset["entry-data-with-swhid"].format(swhid=invalid_swhid)
response = post_atom(
authenticated_client,
reverse(COL_IRI, args=[deposit_collection.name]),
data=xml_data,
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
> assert b"Invalid SWHID reference" in response.content
E assert b'Invalid SWHID reference' in b'<?xml version="1.0" encoding="utf-8"?>\n<sword:error xmlns="http://www.w3.org/2005/Atom"\n xmlns:sword="...med. Please ensure your metadata file is correctly formatted.\n </sword:verboseDescription>\n \n</sword:error>\n'
E + where b'<?xml version="1.0" encoding="utf-8"?>\n<sword:error xmlns="http://www.w3.org/2005/Atom"\n xmlns:sword="...med. Please ensure your metadata file is correctly formatted.\n </sword:verboseDescription>\n \n</sword:error>\n' = <HttpResponse status_code=400, "application/xml">.content
.tox/py3/lib/python3.7/site-packages/swh/deposit/tests/api/test_collection_post_atom.py:516: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Feb 23 2022, 1:52 PM