def test_execute_action(self): action = Action() orig_reverse = Action.reverse orig_swap = Action.swap Action.reverse = Mock() Action.swap = Mock() params = dict(task_id='task_1', cmd='reverse', string='test123') action.execute_action(params) action.reverse.assert_called_once_with(params.get('string')) params = dict(task_id='task_2', cmd='swap', string='test123') action.execute_action(params) action.swap.assert_called_once_with(params.get('string')) Action.reverse = orig_reverse Action.swap = orig_swap