def test_handler_response(self): """ The result of the remote_* method is returned directly from L{MethodHandler.gotResult}. """ mh = MethodHandler() calls = [] mh.remote_foo = lambda **kw: "HOOPLA" result = mh.gotRequest("foo") self.assertEqual(result, "HOOPLA")
def test_invoke_handler(self): """ L{MethodHandler.gotResult} invokes methods named remote_* to handle the requests. """ mh = MethodHandler() calls = [] mh.remote_foo = lambda **kw: calls.append(kw) mh.gotRequest("foo", a=1, b=[1, 2]) self.assertEqual(calls, [{"a": 1, "b": [1, 2]}])
def test_error_response(self): """ Errors from the remote_* method are propagated out directly. """ mh = MethodHandler() calls = [] def remote_foo(): 1 / 0 mh.remote_foo = remote_foo self.assertRaises(ZeroDivisionError, mh.gotRequest, "foo")