Example #1
0
    def test_unbind_failed(self, mock_task_failed, mock_unbind_failed):
        task_id = 'task_1'
        consumer_id = 'consumer_1'
        repo_id = 'repo_1'
        dist_id = 'dist_1'
        call_context = {
            'action': 'unbind',
            'task_id': task_id,
            'consumer_id': consumer_id,
            'repo_id': repo_id,
            'distributor_id': dist_id
        }
        raised = dict(
            exval='Boom',
            xmodule='foo.py',
            xclass=ValueError,
            xstate={'trace': 'stack-trace'},
            xargs=[]
        )
        envelope = Envelope(routing=['A', 'B'], result=raised, any=call_context)
        reply = Failed(envelope)
        handler = ReplyHandler('')
        handler.failed(reply)

        # validate task updated
        mock_task_failed.assert_called_with(task_id, 'stack-trace')
        # validate bind action updated
        mock_unbind_failed.assert_called_with(task_id, call_context)