Ejemplo n.º 1
0
    def test_correct_callback_called(self):
        socket = Mock()
        data = service_call.encode_call('bar', [10])
        socket.recv = Mock(return_value=data)

        service_call.handle_connection(self.handlers, socket)
        self.handlers['bar'].assert_any_call([10])
Ejemplo n.º 2
0
    def test_correct_callback_called(self):
        socket = Mock()
        data = service_call.encode_call('bar', [10])
        socket.recv = Mock(return_value=data)

        service_call.handle_connection(self.handlers, socket)
        self.handlers['bar'].assert_any_call([10])
Ejemplo n.º 3
0
    def test_callback_writeback(self):
        socket = Mock()
        self.handlers['bar'].return_value = 1
        data = service_call.encode_call('bar', [10])
        socket.recv = Mock(return_value=data)

        service_call.handle_connection(self.handlers, socket)

        expected_data = msgpack.packb(1)
        socket.send.assert_any_call(expected_data)
Ejemplo n.º 4
0
    def test_callback_writeback(self):
        socket = Mock()
        self.handlers['bar'].return_value = 1
        data = service_call.encode_call('bar', [10])
        socket.recv = Mock(return_value=data)

        service_call.handle_connection(self.handlers, socket)

        expected_data = msgpack.packb(1)
        socket.send.assert_any_call(expected_data)
Ejemplo n.º 5
0
    def test_multiple_segments(self):
        """
        This tests checks what happens if the data is split between several TCP
        MSS (recv does not return all data in one piece.
        """
        socket = Mock()
        data = service_call.encode_call('bar', [10])
        socket.recv = Mock()
        socket.recv.side_effect = [data[:3], data[3:]]

        service_call.handle_connection(self.handlers, socket)
        self.handlers['bar'].assert_any_call([10])
Ejemplo n.º 6
0
    def test_multiple_segments(self):
        """
        This tests checks what happens if the data is split between several TCP
        MSS (recv does not return all data in one piece.
        """
        socket = Mock()
        data = service_call.encode_call('bar', [10])
        socket.recv = Mock()
        socket.recv.side_effect = [data[:3], data[3:]]

        service_call.handle_connection(self.handlers, socket)
        self.handlers['bar'].assert_any_call([10])