Fix sorting of events

Events should be sorted reverse-chronologically, no matter what order
they come back from the API in, or which field in the API response
they’ve been extracted from.
This commit is contained in:
Chris Hill-Scott
2019-10-23 15:05:26 +01:00
parent 5469119ef0
commit 0185270308
3 changed files with 26 additions and 5 deletions

View File

@@ -3514,11 +3514,17 @@ def mock_get_service_history(mocker):
'created_by_id': uuid4(),
},
{
'name': 'Real service',
'name': 'Before lunch',
'created_at': '2010-10-10T01:01:01.000000Z',
'updated_at': '2012-12-12T12:12:12.000000Z',
'created_by_id': sample_uuid(),
},
{
'name': 'After lunch',
'created_at': '2010-10-10T01:01:01.000000Z',
'updated_at': '2012-12-12T13:13:13.000000Z',
'created_by_id': sample_uuid(),
},
],
'api_key_history': [
{
@@ -3539,6 +3545,12 @@ def mock_get_service_history(mocker):
'created_at': '2011-11-11T11:11:11.000000Z',
'created_by_id': sample_uuid(),
},
{
'name': 'Key event returned in non-chronological order',
'updated_at': None,
'created_at': '2010-10-10T09:09:09.000000Z',
'created_by_id': sample_uuid(),
},
],
'events': [],
})