コード例 #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])
コード例 #2
0
ファイル: test_service_call.py プロジェクト: froj/simplerpc
    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])
コード例 #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)
コード例 #4
0
ファイル: test_service_call.py プロジェクト: froj/simplerpc
    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)
コード例 #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])
コード例 #6
0
ファイル: test_service_call.py プロジェクト: froj/simplerpc
    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])