Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/common.py
Show First 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | def setUp(self): | ||||
<url>https://hal-test.archives-ouvertes.fr/some-external-id</url> | <url>https://hal-test.archives-ouvertes.fr/some-external-id</url> | ||||
<author>some awesome author</author> | <author>some awesome author</author> | ||||
</entry>""" | </entry>""" | ||||
self.atom_entry_data1 = b"""<?xml version="1.0"?> | self.atom_entry_data1 = b"""<?xml version="1.0"?> | ||||
<entry xmlns="http://www.w3.org/2005/Atom"> | <entry xmlns="http://www.w3.org/2005/Atom"> | ||||
<author>another one</author> | <author>another one</author> | ||||
<author>no one</author> | <author>no one</author> | ||||
<codemeta:dateCreated>2017-10-07T15:17:08Z</codemeta:dateCreated> | |||||
</entry>""" | </entry>""" | ||||
self.atom_entry_data2 = b"""<?xml version="1.0"?> | self.atom_entry_data2 = b"""<?xml version="1.0"?> | ||||
<entry xmlns="http://www.w3.org/2005/Atom"> | <entry xmlns="http://www.w3.org/2005/Atom"> | ||||
<title>Awesome Compiler</title> | <title>Awesome Compiler</title> | ||||
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> | <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> | ||||
<external_identifier>1785io25c695</external_identifier> | <external_identifier>1785io25c695</external_identifier> | ||||
<updated>2017-10-07T15:17:08Z</updated> | <updated>2017-10-07T15:17:08Z</updated> | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | def create_deposit_partial_with_data_in_args(self, data): | ||||
Args: | Args: | ||||
data: atom entry | data: atom entry | ||||
Returns: | Returns: | ||||
deposit id | deposit id | ||||
""" | """ | ||||
if isinstance(data, str): | |||||
data = data.encode('utf-8') | |||||
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=data, | data=data, | ||||
HTTP_SLUG='external-id', | HTTP_SLUG='external-id', | ||||
HTTP_IN_PROGRESS='true') | HTTP_IN_PROGRESS='true') | ||||
assert response.status_code == status.HTTP_201_CREATED | assert response.status_code == status.HTTP_201_CREATED | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |