def testGetDaysInStates(self): """ Work is getting stuck in CA for ages. We want to see for how long. To start with we'll just find out how long has something been in its current state """ histories = [mockHistory(u'2012-11-18T09:54:29.284+0000', [mockItem('status', 'queued', START_STATE)]), mockHistory(u'2012-11-28T09:54:29.284+0000', [mockItem('status', START_STATE, 'pending')]), mockHistory(u'2012-11-30T09:54:29.284+0000', [mockItem('status', 'pending', END_STATE)])] created = date(2012, 11, 16) today = date(2012, 12, 02) actual = time_in_states(histories, created, today) expected = [{'state': 'Open', 'days': 2}, {'state': START_STATE, 'days': 10}, {'state': 'pending', 'days': 2}, {'state': END_STATE, 'days': 2}] assert actual == expected, actual
def testGetDaysInStates(self): """ Work is getting stuck in CA for ages. We want to see for how long. To start with we'll just find out how long has something been in its current state """ histories = [ mockHistory(u'2012-11-18T09:54:29.284+0000', [mockItem('status', 'queued', START_STATE)]), mockHistory(u'2012-11-28T09:54:29.284+0000', [mockItem('status', START_STATE, 'pending')]), mockHistory(u'2012-11-30T09:54:29.284+0000', [mockItem('status', 'pending', END_STATE)]) ] created = date(2012, 11, 16) today = date(2012, 12, 02) actual = time_in_states(histories, created, today) expected = [{ 'state': 'Open', 'days': 2 }, { 'state': START_STATE, 'days': 10 }, { 'state': 'pending', 'days': 2 }, { 'state': END_STATE, 'days': 2 }] assert actual == expected, actual
def testGetTimeInStatesWithNoHistory(self): """ If a ticket has not left its initial state then it has no explict history so we need to create one for it based on how long it has been in this initial state. """ created = date(2012, 11, 16) today = date(2012, 12, 02) expected = [{'state': 'Open', 'days': 16}] actual = time_in_states([], created, today) assert actual == expected, actual