def make_connection(self):
     c = AsyncoreConnection('1.2.3.4',
                            cql_version='3.0.1',
                            connect_timeout=5)
     c.socket = Mock()
     c.socket.send.side_effect = lambda x: len(x)
     return c
Пример #2
0
    def setUpClass(cls):
        AsyncoreConnection.initialize_reactor()
        cls.socket_patcher = patch('socket.socket', spec=socket.socket)
        cls.mock_socket = cls.socket_patcher.start()
        cls.mock_socket().connect_ex.return_value = 0
        cls.mock_socket().getsockopt.return_value = 0
        cls.mock_socket().fileno.return_value = 100

        AsyncoreConnection.add_channel = lambda *args, **kwargs: None
    def setUpClass(cls):
        AsyncoreConnection.initialize_reactor()
        cls.socket_patcher = patch('socket.socket', spec=socket.socket)
        cls.mock_socket = cls.socket_patcher.start()
        cls.mock_socket().connect_ex.return_value = 0
        cls.mock_socket().getsockopt.return_value = 0
        cls.mock_socket().fileno.return_value = 100

        AsyncoreConnection.add_channel = lambda *args, **kwargs: None
    def setUpClass(cls):
        if 'gevent.monkey' in sys.modules:
            raise unittest.SkipTest("gevent monkey-patching detected")
        AsyncoreConnection.initialize_reactor()
        cls.socket_patcher = patch('socket.socket', spec=socket.socket)
        cls.mock_socket = cls.socket_patcher.start()
        cls.mock_socket().connect_ex.return_value = 0
        cls.mock_socket().getsockopt.return_value = 0
        cls.mock_socket().fileno.return_value = 100

        AsyncoreConnection.add_channel = lambda *args, **kwargs: None
Пример #5
0
    def setUpClass(cls):
        if is_monkey_patched():
            raise unittest.SkipTest("monkey-patching detected")
        AsyncoreConnection.initialize_reactor()
        cls.socket_patcher = patch('socket.socket', spec=socket.socket)
        cls.mock_socket = cls.socket_patcher.start()
        cls.mock_socket().connect_ex.return_value = 0
        cls.mock_socket().getsockopt.return_value = 0
        cls.mock_socket().fileno.return_value = 100

        AsyncoreConnection.add_channel = lambda *args, **kwargs: None
Пример #6
0
    def setUpClass(cls):
        if is_monkey_patched():
            return
        AsyncoreConnection.initialize_reactor()

        socket_patcher = patch('socket.socket', spec=socket.socket)
        channel_patcher = patch(
            'cassandra.io.asyncorereactor.AsyncoreConnection.add_channel',
            new=(lambda *args, **kwargs: None))

        cls.mock_socket = socket_patcher.start()
        cls.mock_socket.connect_ex.return_value = 0
        cls.mock_socket.getsockopt.return_value = 0
        cls.mock_socket.fileno.return_value = 100

        channel_patcher.start()

        cls.patchers = (socket_patcher, channel_patcher)
    def setUpClass(cls):
        if is_monkey_patched():
            return
        AsyncoreConnection.initialize_reactor()

        socket_patcher = patch('socket.socket', spec=socket.socket)
        channel_patcher = patch(
            'cassandra.io.asyncorereactor.AsyncoreConnection.add_channel',
            new=(lambda *args, **kwargs: None)
        )

        cls.mock_socket = socket_patcher.start()
        cls.mock_socket.connect_ex.return_value = 0
        cls.mock_socket.getsockopt.return_value = 0
        cls.mock_socket.fileno.return_value = 100

        channel_patcher.start()

        cls.patchers = (socket_patcher, channel_patcher)
 def make_connection(self):
     c = AsyncoreConnection('1.2.3.4', cql_version='3.0.1')
     c.socket = Mock()
     c.socket.send.side_effect = lambda x: len(x)
     return c
Пример #9
0
 def setUpClass(cls):
     AsyncoreConnection.initialize_reactor()
     cls.socket_patcher = patch('socket.socket', spec=socket.socket)
     cls.mock_socket = cls.socket_patcher.start()
     cls.mock_socket().connect_ex.return_value = 0
     cls.mock_socket().getsockopt.return_value = 0
Пример #10
0
 def setUpClass(cls):
     AsyncoreConnection.initialize_reactor()
     cls.socket_patcher = patch('socket.socket', spec=socket.socket)
     cls.mock_socket = cls.socket_patcher.start()
     cls.mock_socket().connect_ex.return_value = 0
     cls.mock_socket().getsockopt.return_value = 0