コード例 #1
0
ファイル: unittests.py プロジェクト: cbart/sik-lab
class TestRPCClient(TestCase):

    _SERVER_HOST = 'localhost'
    _SERVER_PORT = None

    _LOGIN = '******'
    _PASSWORD = '******'
    _IP = '192.168.0.1'
    _PORT = 11381

    def setUp_1999_findFreshPort(self):

        self._SERVER_PORT = findPort()

    def tearDown_1999_findFreshPort(self):

        self._SERVER_PORT = None

    def setUp_2000_rpcServer(self):

        self.rpc_mock_instance = RPCMock()
        self.rpc_server_instance = RPCServer(
                self._SERVER_HOST,
                self._SERVER_PORT,
                self.rpc_mock_instance)
        self.rpc_server_instance.run()

    def tearDown_2000_rpcServer(self):

        self.rpc_client = None
        self.rpc_server_instance.stop()
        self.rpc_server_instance = None
        self.rpc_mock_instance = None

    def setUp_2001_rpcClient(self):

        self.rpc_client = RPCClient(
                "http://%s:%d/" % (self._SERVER_HOST, self._SERVER_PORT))

    def tearDown_2001_rpcClient(self):

        self.rpc_client = None

    def testIsConnected(self):

        self.assertFalse(self.rpc_client.call_action('isConnected'))
        self.assertTrue(self.rpc_client.call_action('connect',
            self._IP, self._PORT))
        self.assertTrue(self.rpc_client.call_action('isConnected'))
        self.assertTrue(self.rpc_client.call_action('disconnect'))
        self.assertFalse(self.rpc_client.call_action('isConnected'))
コード例 #2
0
ファイル: unittests.py プロジェクト: cbart/sik-lab
    def setUp_2001_rpcClient(self):

        self.rpc_client = RPCClient(
                "http://%s:%d/" % (self._SERVER_HOST, self._SERVER_PORT))