@patch('tests.test_transition.debug_action')
def test_failure_callback_exception_passed(self, debug_mock):
    update_invoice(self.invoice, is_available=True, customer_received=True)
    transition = Transition('test', sources=[], target='success', failed_state='failed', side_effects=[fail_invoice], failure_callbacks=[debug_action])
    self.invoice.refresh_from_db()
    state = State(self.invoice, 'status')
    transition.change_state(state, foo='bar')
    self.assertTrue(debug_mock.called)
    self.assertEqual(debug_mock.call_count, 1)
    call_args = debug_mock.call_args[0]
    call_kwargs = debug_mock.call_args[1]
    self.assertEqual(call_args, (self.invoice,))
    self.assertEqual(len(call_kwargs), 2)
    self.assertTrue(isinstance(call_kwargs['exception'], Exception))
    self.assertEqual(call_kwargs['foo'], 'bar')
@patch('tests.test_transition.debug_action')
def test_failure_callback_exception_passed(self, debug_mock):
    update_invoice(self.invoice, is_available=True, customer_received=True)
    transition = Transition('test', sources=[], target='success', failed_state='failed', side_effects=[fail_invoice], failure_callbacks=[debug_action])
    self.invoice.refresh_from_db()
    state = State(self.invoice, 'status')
    transition.change_state(state, foo='bar')
    self.assertTrue(debug_mock.called)
    self.assertEqual(debug_mock.call_count, 1)
    call_args = debug_mock.call_args[0]
    call_kwargs = debug_mock.call_args[1]
    self.assertEqual(call_args, (self.invoice,))
    self.assertEqual(len(call_kwargs), 2)
    self.assertTrue(isinstance(call_kwargs['exception'], Exception))
    self.assertEqual(call_kwargs['foo'], 'bar')