stash
This commit is contained in:
parent
65b5a8b8b2
commit
8cedbb5180
2 changed files with 29 additions and 12 deletions
|
@ -105,6 +105,14 @@ class ItemSerializer(BasicItemSerializer):
|
||||||
'timestamp': relation.timestamp,
|
'timestamp': relation.timestamp,
|
||||||
'issue_thread': BasicIssueSerializer(relation.issue_thread).data,
|
'issue_thread': BasicIssueSerializer(relation.issue_thread).data,
|
||||||
})
|
})
|
||||||
|
for placement in (obj.container_history.all()):
|
||||||
|
timeline.append({
|
||||||
|
'type': 'placement',
|
||||||
|
'id': placement.id,
|
||||||
|
'timestamp': placement.timestamp,
|
||||||
|
'cid': placement.container.id,
|
||||||
|
'box': placement.container.name
|
||||||
|
})
|
||||||
return sorted(timeline, key=lambda x: x['timestamp'])
|
return sorted(timeline, key=lambda x: x['timestamp'])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,20 +63,29 @@ class ItemTestCase(TestCase):
|
||||||
self.assertEqual(response.json()[0]['file'], None)
|
self.assertEqual(response.json()[0]['file'], None)
|
||||||
self.assertEqual(response.json()[0]['returned'], False)
|
self.assertEqual(response.json()[0]['returned'], False)
|
||||||
self.assertEqual(response.json()[0]['event'], self.event.slug)
|
self.assertEqual(response.json()[0]['event'], self.event.slug)
|
||||||
self.assertEqual(len(response.json()[0]['timeline']), 2)
|
self.assertEqual(len(response.json()[0]['timeline']), 4)
|
||||||
self.assertEqual(response.json()[0]['timeline'][0]['type'], 'comment')
|
self.assertEqual(response.json()[0]['timeline'][0]['type'], 'placement')
|
||||||
self.assertEqual(response.json()[0]['timeline'][1]['type'], 'issue_relation')
|
self.assertEqual(response.json()[0]['timeline'][1]['type'], 'comment')
|
||||||
self.assertEqual(response.json()[0]['timeline'][0]['id'], comment.id)
|
self.assertEqual(response.json()[0]['timeline'][2]['type'], 'issue_relation')
|
||||||
self.assertEqual(response.json()[0]['timeline'][1]['id'], match.id)
|
self.assertEqual(response.json()[0]['timeline'][3]['type'], 'placement')
|
||||||
self.assertEqual(response.json()[0]['timeline'][0]['comment'], 'test')
|
self.assertEqual(response.json()[0]['timeline'][1]['id'], comment.id)
|
||||||
self.assertEqual(response.json()[0]['timeline'][0]['timestamp'],
|
self.assertEqual(response.json()[0]['timeline'][2]['id'], match.id)
|
||||||
comment.timestamp.strftime('%Y-%m-%dT%H:%M:%S.%fZ'))
|
self.assertEqual(response.json()[0]['timeline'][3]['id'], placement.id)
|
||||||
self.assertEqual(response.json()[0]['timeline'][1]['status'], 'possible')
|
self.assertEqual(response.json()[0]['timeline'][0]['box'], 'BOX1')
|
||||||
|
self.assertEqual(response.json()[0]['timeline'][0]['cid'], self.box1.id)
|
||||||
|
self.assertEqual(response.json()[0]['timeline'][1]['comment'], 'test')
|
||||||
self.assertEqual(response.json()[0]['timeline'][1]['timestamp'],
|
self.assertEqual(response.json()[0]['timeline'][1]['timestamp'],
|
||||||
|
comment.timestamp.strftime('%Y-%m-%dT%H:%M:%S.%fZ'))
|
||||||
|
self.assertEqual(response.json()[0]['timeline'][2]['status'], 'possible')
|
||||||
|
self.assertEqual(response.json()[0]['timeline'][2]['timestamp'],
|
||||||
match.timestamp.strftime('%Y-%m-%dT%H:%M:%S.%fZ'))
|
match.timestamp.strftime('%Y-%m-%dT%H:%M:%S.%fZ'))
|
||||||
self.assertEqual(response.json()[0]['timeline'][1]['issue_thread']['name'], "test issue")
|
self.assertEqual(response.json()[0]['timeline'][2]['issue_thread']['name'], "test issue")
|
||||||
self.assertEqual(response.json()[0]['timeline'][1]['issue_thread']['event'], "EVENT")
|
self.assertEqual(response.json()[0]['timeline'][2]['issue_thread']['event'], "EVENT")
|
||||||
self.assertEqual(response.json()[0]['timeline'][1]['issue_thread']['state'], "pending_new")
|
self.assertEqual(response.json()[0]['timeline'][2]['issue_thread']['state'], "pending_new")
|
||||||
|
self.assertEqual(response.json()[0]['timeline'][3]['box'], 'BOX2')
|
||||||
|
self.assertEqual(response.json()[0]['timeline'][3]['cid'], self.box2.id)
|
||||||
|
self.assertEqual(response.json()[0]['timeline'][3]['timestamp'],
|
||||||
|
placement.timestamp.strftime('%Y-%m-%dT%H:%M:%S.%fZ'))
|
||||||
self.assertEqual(len(response.json()[0]['related_issues']), 1)
|
self.assertEqual(len(response.json()[0]['related_issues']), 1)
|
||||||
self.assertEqual(response.json()[0]['related_issues'][0]['name'], "test issue")
|
self.assertEqual(response.json()[0]['related_issues'][0]['name'], "test issue")
|
||||||
self.assertEqual(response.json()[0]['related_issues'][0]['event'], "EVENT")
|
self.assertEqual(response.json()[0]['related_issues'][0]['event'], "EVENT")
|
||||||
|
|
Loading…
Add table
Reference in a new issue