def test_finalize_with_done_success(self): """Testing StatusUpdatesEntryMixin.finalize with DONE_SUCCESS""" entry = StatusUpdatesEntryMixin() entry.add_update(StatusUpdate(state=StatusUpdate.DONE_SUCCESS)) entry.finalize() self.assertEqual(entry.state_summary, '1 succeeded') self.assertEqual(entry.state_summary_class, 'status-update-state-success')
def test_finalize_with_pending(self): """Testing StatusUpdatesEntryMixin.finalize with PENDING""" entry = StatusUpdatesEntryMixin() entry.add_update(StatusUpdate(state=StatusUpdate.PENDING)) entry.finalize() self.assertEqual(entry.state_summary, '1 pending') self.assertEqual(entry.state_summary_class, 'status-update-state-pending')
def test_finalize_with_timeout(self): """Testing StatusUpdatesEntryMixin.finalize with TIMEOUT""" entry = StatusUpdatesEntryMixin() entry.add_update(StatusUpdate(state=StatusUpdate.TIMEOUT)) entry.finalize() self.assertEqual(entry.state_summary, '1 timed out') self.assertEqual(entry.state_summary_class, 'status-update-state-failure')
def test_finalize_with_error(self): """Testing StatusUpdatesEntryMixin.finalize with ERROR""" entry = StatusUpdatesEntryMixin() entry.add_update(StatusUpdate(state=StatusUpdate.ERROR)) entry.finalize() self.assertEqual(entry.state_summary, '1 failed with error') self.assertEqual(entry.state_summary_class, 'status-update-state-failure')
def test_finalize_with_done_failure(self): """Testing StatusUpdatesEntryMixin.finalize with DONE_FAILURE""" entry = StatusUpdatesEntryMixin() entry.add_update(StatusUpdate(state=StatusUpdate.DONE_FAILURE)) entry.finalize() self.assertEqual(entry.state_summary, '1 failed') self.assertEqual(entry.state_summary_class, 'status-update-state-failure')
def test_finalize_with_pending_take_precedence(self): """Testing StatusUpdatesEntryMixin.finalize with PENDING taking precedence SUCCESS """ entry = StatusUpdatesEntryMixin() entry.add_update(StatusUpdate(state=StatusUpdate.PENDING)) entry.add_update(StatusUpdate(state=StatusUpdate.DONE_SUCCESS)) entry.finalize() self.assertEqual(entry.state_summary, '1 succeeded, 1 pending') self.assertEqual(entry.state_summary_class, 'status-update-state-pending')
def test_finalize_with_failures_take_precedence(self): """Testing StatusUpdatesEntryMixin.finalize with failures taking precedence over PENDING and DONE_SUCCESS """ entry = StatusUpdatesEntryMixin() entry.add_update(StatusUpdate(state=StatusUpdate.DONE_FAILURE)) entry.add_update(StatusUpdate(state=StatusUpdate.PENDING)) entry.add_update(StatusUpdate(state=StatusUpdate.DONE_SUCCESS)) entry.finalize() self.assertEqual(entry.state_summary, '1 failed, 1 succeeded, 1 pending') self.assertEqual(entry.state_summary_class, 'status-update-state-failure')
def test_finalize_with_all_states(self): """Testing StatusUpdatesEntryMixin.finalize with all states""" entry = StatusUpdatesEntryMixin() entry.add_update(StatusUpdate(state=StatusUpdate.DONE_FAILURE)) for i in range(2): entry.add_update(StatusUpdate(state=StatusUpdate.DONE_SUCCESS)) for i in range(3): entry.add_update(StatusUpdate(state=StatusUpdate.PENDING)) for i in range(4): entry.add_update(StatusUpdate(state=StatusUpdate.ERROR)) for i in range(5): entry.add_update(StatusUpdate(state=StatusUpdate.TIMEOUT)) entry.finalize() self.assertEqual( entry.state_summary, '1 failed, 2 succeeded, 3 pending, 4 failed with error, ' '5 timed out')