Skip to content
Snippets Groups Projects
Verified Commit aeeab63f authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

api/deposit_status: Fix unexpected type error

Ids can be other types than string, join will not work on those.
This commit fixes it.
parent a90ba7e8
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,7 @@ def convert_status_detail(status_detail):
suffix_msg = ''
fields = data.get('fields')
if fields:
suffix_msg = ' (%s)' % ', '.join(fields)
suffix_msg = ' (%s)' % ', '.join(map(str, fields))
msg.append('- %s%s\n' % (data['summary'], suffix_msg))
_detail = status_detail.get('url')
......@@ -60,7 +60,7 @@ def convert_status_detail(status_detail):
fields = _detail.get('fields')
suffix_msg = ''
if fields:
suffix_msg = ' (%s)' % ', '.join(fields)
suffix_msg = ' (%s)' % ', '.join(map(str, fields))
msg.append('- %s%s\n' % (_detail['summary'], suffix_msg))
if not msg:
......
......@@ -218,6 +218,41 @@ class DepositStatusTestCase(APITestCase, WithAuthTestCase, BasicTestCase,
actual_status_detail = convert_status_detail(status_detail)
self.assertEqual(actual_status_detail, expected_status_detail)
@istest
def convert_status_detail_edge_case(self):
status_detail = {
'url': {
'summary': 'At least one compatible url field. Failed',
'fields': ['testurl'],
},
'metadata': [
{
'summary': 'Mandatory fields missing',
'fields': ['9', 10, 1.212],
},
],
'archive': [
{
'summary': 'Invalid archive',
'fields': ['3'],
},
{
'summary': 'Unsupported archive',
'fields': [2],
}
],
}
expected_status_detail = '''- Mandatory fields missing (9, 10, 1.212)
- Invalid archive (3)
- Unsupported archive (2)
- At least one compatible url field. Failed (testurl)
'''
actual_status_detail = convert_status_detail(status_detail)
self.assertEqual(actual_status_detail, expected_status_detail)
@istest
def status_on_deposit_rejected(self):
_status = DEPOSIT_STATUS_REJECTED
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment