Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_deposit_atom.py
Show First 20 Lines • Show All 291 Lines • ▼ Show 20 Lines | def test_post_deposit_atom_badly_formatted_is_a_bad_request(self): | ||||
""" | """ | ||||
response = self.client.post( | response = self.client.post( | ||||
reverse(COL_IRI, args=[self.collection.name]), | reverse(COL_IRI, args=[self.collection.name]), | ||||
content_type='application/atom+xml;type=entry', | content_type='application/atom+xml;type=entry', | ||||
data=self.atom_entry_data_badly_formatted) | data=self.atom_entry_data_badly_formatted) | ||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||||
def test_post_deposit_atom_without_slug_header_is_bad_request(self): | def test_post_deposit_atom_without_slug_header_is_bad_request(self): | ||||
def test_post_deposit_atom_400_with_parsing_error(self): | |||||
"""Posting parsing error prone atom should return 400 | |||||
""" | |||||
atom_entry_data_parsing_error_prone = b"""<?xml version="1.0"?> | |||||
<entry xmlns="http://www.w3.org/2005/Atom"</entry> | |||||
<title>Composing a Web of Audio Applications</title> | |||||
<clienhal</client> | |||||
</entry> | |||||
""" | |||||
response = self.client.post( | |||||
reverse(COL_IRI, args=[self.collection.name]), | |||||
content_type='application/atom+xml;type=entry', | |||||
data=atom_entry_data_parsing_error_prone) | |||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | |||||
"""Posting an atom entry without a slug header should return a 400 | """Posting an atom entry without a slug header should return a 400 | ||||
""" | """ | ||||
url = reverse(COL_IRI, args=[self.collection.name]) | url = reverse(COL_IRI, args=[self.collection.name]) | ||||
# when | # when | ||||
response = self.client.post( | response = self.client.post( | ||||
url, | url, | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | def test_post_deposit_atom_entry_multiple_steps(self): | ||||
self.assertEqual(deposit.status, 'partial') | self.assertEqual(deposit.status, 'partial') | ||||
self.assertEqual(deposit.client, self.user) | self.assertEqual(deposit.client, self.user) | ||||
# one associated request to a deposit | # one associated request to a deposit | ||||
deposit_requests = DepositRequest.objects.filter(deposit=deposit) | deposit_requests = DepositRequest.objects.filter(deposit=deposit) | ||||
self.assertEqual(len(deposit_requests), 1) | self.assertEqual(len(deposit_requests), 1) | ||||
atom_entry_data = self.atom_entry_data2 % external_id.encode('utf-8') | atom_entry_data = self.atom_entry_data2 % external_id.encode('utf-8') | ||||
moranegg: I need to find the real reference to external_id, because I don't know from which vocabulary it… | |||||
update_uri = response._headers['location'][1] | update_uri = response._headers['location'][1] | ||||
# when updating the first deposit post | # when updating the first deposit post | ||||
response = self.client.post( | response = self.client.post( | ||||
update_uri, | update_uri, | ||||
content_type='application/atom+xml;type=entry', | content_type='application/atom+xml;type=entry', | ||||
data=atom_entry_data, | data=atom_entry_data, | ||||
HTTP_IN_PROGRESS='False') | HTTP_IN_PROGRESS='False') | ||||
Show All 38 Lines |
I need to find the real reference to external_id, because I don't know from which vocabulary it is.
This is not a blocker for this diff.