コード例 #1
0
ファイル: test_rpc.py プロジェクト: zouxiaoliang/mprpc
    def test_open_and_close(self, mock_socket):
        mock_socket_ins = Mock()
        mock_socket.create_connection.return_value = mock_socket_ins

        client = RPCClient(HOST, PORT)

        ok_(client.is_connected())

        mock_socket.create_connection.assert_called_once_with((HOST, PORT))

        client.close()

        ok_(mock_socket_ins.close.called)
        ok_(not client.is_connected())
コード例 #2
0
ファイル: test_rpc.py プロジェクト: david-cliqz/mprpc
    def test_open_and_close(self, mock_socket):
        mock_socket_ins = Mock()
        mock_socket.create_connection.return_value = mock_socket_ins

        client = RPCClient(HOST, PORT)

        ok_(client.is_connected())

        mock_socket.create_connection.assert_called_once_with((HOST, PORT))

        client.close()

        ok_(mock_socket_ins.close.called)
        ok_(not client.is_connected())
コード例 #3
0
    def test_open_and_close_unix_socket(self, mock_socket):
        mock_socket_ins = Mock()
        mock_socket.socket.return_value = mock_socket_ins

        client = RPCClient(unix_socket_path=UNIX_SOCK_PATH)
        mock_socket.socket.assert_called_once_with(mock_socket.AF_UNIX, mock_socket.SOCK_STREAM)

        ok_(client.is_connected())

        mock_socket_ins.connect.assert_called_once_with(UNIX_SOCK_PATH)

        client.close()

        ok_(mock_socket_ins.close.called)
        ok_(not client.is_connected())
コード例 #4
0
ファイル: test_rpc.py プロジェクト: zouxiaoliang/mprpc
    def test_open_with_timeout(self, mock_socket):
        mock_socket_ins = Mock()
        mock_socket.create_connection.return_value = mock_socket_ins

        client = RPCClient(HOST, PORT, timeout=5.0)

        mock_socket_ins.settimeout.assert_called_once_with(5.0)
        ok_(client.is_connected())
コード例 #5
0
ファイル: test_rpc.py プロジェクト: david-cliqz/mprpc
    def test_open_with_timeout(self, mock_socket):
        mock_socket_ins = Mock()
        mock_socket.create_connection.return_value = mock_socket_ins

        client = RPCClient(HOST, PORT, timeout=5.0)

        mock_socket_ins.settimeout.assert_called_once_with(5.0)
        ok_(client.is_connected())
コード例 #6
0
    def test_open_unix_socket_with_timeout(self, mock_socket):
        mock_socket_ins = Mock()
        mock_socket.socket.return_value = mock_socket_ins

        client = RPCClient(unix_socket_path=UNIX_SOCK_PATH, timeout=5.0)

        mock_socket_ins.settimeout.assert_called_once_with(5.0)
        ok_(client.is_connected())