Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_deposit_status.py
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | def convert_status_detail(self): | ||||
'summary': 'Mandatory fields missing', | 'summary': 'Mandatory fields missing', | ||||
'fields': ['url', 'title'], | 'fields': ['url', 'title'], | ||||
}, | }, | ||||
{ | { | ||||
'summary': 'Alternate fields missing', | 'summary': 'Alternate fields missing', | ||||
'fields': ['name or title', 'url or badurl'] | 'fields': ['name or title', 'url or badurl'] | ||||
} | } | ||||
], | ], | ||||
'archive': { | 'archive': [{ | ||||
'summary': 'Unreadable archive', | 'summary': 'Unreadable archive', | ||||
'fields': ['1', '2'], | 'fields': ['1'], | ||||
}, | }], | ||||
} | } | ||||
expected_status_detail = '''- Mandatory fields missing (url, title) | expected_status_detail = '''- Mandatory fields missing (url, title) | ||||
- Alternate fields missing (name or title, url or badurl) | - Alternate fields missing (name or title, url or badurl) | ||||
- Unreadable archive (1) | |||||
- At least one url field must be compatible with the client's domain name. The following url fields failed the check (blahurl, testurl) | - At least one url field must be compatible with the client's domain name. The following url fields failed the check (blahurl, testurl) | ||||
- Unreadable archive (1, 2) | |||||
''' # noqa | ''' # noqa | ||||
actual_status_detail = convert_status_detail(status_detail) | actual_status_detail = convert_status_detail(status_detail) | ||||
self.assertEqual(actual_status_detail, expected_status_detail) | self.assertEqual(actual_status_detail, expected_status_detail) | ||||
@istest | @istest | ||||
def convert_status_detail_2(self): | def convert_status_detail_2(self): | ||||
status_detail = { | status_detail = { | ||||
'url': { | 'url': { | ||||
'summary': 'At least one compatible url field. Failed', | 'summary': 'At least one compatible url field. Failed', | ||||
'fields': ['testurl'], | 'fields': ['testurl'], | ||||
}, | }, | ||||
'metadata': [ | 'metadata': [ | ||||
{ | { | ||||
'summary': 'Mandatory fields missing', | 'summary': 'Mandatory fields missing', | ||||
'fields': ['name'], | 'fields': ['name'], | ||||
}, | }, | ||||
], | ], | ||||
'archive': [ | |||||
{ | |||||
'summary': 'Invalid archive', | |||||
'fields': ['2'], | |||||
}, | |||||
{ | |||||
'summary': 'Unsupported archive', | |||||
'fields': ['1'], | |||||
} | |||||
], | |||||
} | } | ||||
expected_status_detail = '''- Mandatory fields missing (name) | expected_status_detail = '''- Mandatory fields missing (name) | ||||
- Invalid archive (2) | |||||
- Unsupported archive (1) | |||||
- At least one compatible url field. Failed (testurl) | - At least one compatible url field. Failed (testurl) | ||||
''' | ''' | ||||
actual_status_detail = convert_status_detail(status_detail) | actual_status_detail = convert_status_detail(status_detail) | ||||
self.assertEqual(actual_status_detail, expected_status_detail) | self.assertEqual(actual_status_detail, expected_status_detail) | ||||
@istest | @istest | ||||
Show All 33 Lines |