def _test_client_generate_with_parameter(self, methods): klz = ClientInternetSocket.generate(methods) for method_name in methods: self.assertTrue( hasattr(klz, method_name), "generate() was intended to generate a class with the method %s" % method_name) self.assertNotEquals(getattr(klz, method_name).__doc__.find(method_name), -1, "%s() has not its name in its docstring" % method_name) self.assertTrue( hasattr(klz, "test_me"), "generate() was intended to generate a class with the method test_me()") return klz
def _test_client_generate_with_parameter(self, methods): klz = ClientInternetSocket.generate(methods) for method_name in methods: self.assertTrue( hasattr(klz, method_name), "generate() was intended to generate a class with the method %s" % method_name) self.assertNotEquals( getattr(klz, method_name).__doc__.find(method_name), -1, "%s() has not its name in its docstring" % method_name) self.assertTrue( hasattr(klz, "test_me"), "generate() was intended to generate a class with the method test_me()" ) return klz
def test_server_on_request_off(self): methods = ["method0", "method1", "method2"] klz_server = ServerInternetSocket.generate(self.cfg_manager, methods) server = klz_server("127.0.0.1", PORT + 2) parent = TestServer() server.register_parent(parent) server.start(False) klz_client = ClientInternetSocket.generate(methods) client = klz_client("127.0.0.1", PORT + 2) result = client.method0() self.assertEquals(result, "This is the result of method0()") result = client.method1("foobar") self.assertEquals(result, "This is the result of method1() (arg1=foobar)") result = client.method2("foo", "bar") self.assertEquals(result, "This is the result of method2() (arg1=foo and arg2=bar)") server.stop()
def test_server_on_request_off(self): methods = ["method0", "method1", "method2"] klz_server = ServerInternetSocket.generate(self.cfg_manager, methods) server = klz_server("127.0.0.1", PORT + 2) parent = TestServer() server.register_parent(parent) server.start(False) klz_client = ClientInternetSocket.generate(methods) client = klz_client("127.0.0.1", PORT + 2) result = client.method0() self.assertEquals(result, "This is the result of method0()") result = client.method1("foobar") self.assertEquals(result, "This is the result of method1() (arg1=foobar)") result = client.method2("foo", "bar") self.assertEquals( result, "This is the result of method2() (arg1=foo and arg2=bar)") server.stop()