def test_push_task(): ac = flexmock() ac.should_receive('list').and_return(defer.succeed(['foo', 'bar'])).once() def configure(binder): binder.bind(ApplicationController, ac) with inject_services(configure): ts = TaskService() r = yield ts.task_list(123123) assert r == ['foo', 'bar']