Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/common.py
Show First 20 Lines • Show All 432 Lines • ▼ Show 20 Lines | def create_deposit_with_invalid_archive(self, | ||||
HTTP_CONTENT_DISPOSITION='attachment; filename=filename0') | HTTP_CONTENT_DISPOSITION='attachment; filename=filename0') | ||||
response_content = parse_xml(BytesIO(response.content)) | response_content = parse_xml(BytesIO(response.content)) | ||||
deposit_id = int(response_content['deposit_id']) | deposit_id = int(response_content['deposit_id']) | ||||
return deposit_id | return deposit_id | ||||
def create_deposit_with_status( | def create_deposit_with_status( | ||||
self, status, | self, status, | ||||
external_id='some-external-id-1', swh_id=None, status_detail=None): | external_id='some-external-id-1', | ||||
swh_id=None, | |||||
swh_id_context=None, | |||||
swh_anchor_id=None, | |||||
swh_anchor_id_context=None, | |||||
status_detail=None): | |||||
# create an invalid deposit which we will update further down the line | # create an invalid deposit which we will update further down the line | ||||
deposit_id = self.create_deposit_with_invalid_archive(external_id) | deposit_id = self.create_deposit_with_invalid_archive(external_id) | ||||
# We cannot create some form of deposit with a given status in | # We cannot create some form of deposit with a given status in | ||||
# test context ('rejected' for example). Update in place the | # test context ('rejected' for example). Update in place the | ||||
# deposit with such status to permit some further tests. | # deposit with such status to permit some further tests. | ||||
deposit = Deposit.objects.get(pk=deposit_id) | deposit = Deposit.objects.get(pk=deposit_id) | ||||
if status == DEPOSIT_STATUS_REJECTED: | if status == DEPOSIT_STATUS_REJECTED: | ||||
deposit.status_detail = status_detail | deposit.status_detail = status_detail | ||||
deposit.status = status | deposit.status = status | ||||
if swh_id: | if swh_id: | ||||
deposit.swh_id = swh_id | deposit.swh_id = swh_id | ||||
if swh_id_context: | |||||
deposit.swh_id_context = swh_id_context | |||||
if swh_anchor_id: | |||||
deposit.swh_anchor_id = swh_anchor_id | |||||
if swh_anchor_id_context: | |||||
deposit.swh_anchor_id_context = swh_anchor_id_context | |||||
deposit.save() | deposit.save() | ||||
return deposit_id | return deposit_id | ||||
def create_simple_deposit_partial(self, external_id='some-external-id'): | def create_simple_deposit_partial(self, external_id='some-external-id'): | ||||
"""Create a simple deposit (1 request) in `partial` state and returns | """Create a simple deposit (1 request) in `partial` state and returns | ||||
its new identifier. | its new identifier. | ||||
Returns: | Returns: | ||||
deposit id | deposit id | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |