def test_should_write_query_to_socket(self, mock_socket, format_answer):
        mock_socket.return_value.recv.side_effect = [b"{}", None]
        format_answer.side_effect = lambda _, x, __: x

        perform_query("test", "/path/to/socket")

        mock_socket.return_value.send.assert_called_with(b"test\nOutputFormat: json\n")
示例#2
0
    def test_should_write_query_to_socket(self, mock_socket, format_answer):
        mock_socket.return_value.recv.side_effect = [b'{}', None]
        format_answer.side_effect = lambda _, x, __: x

        perform_query('test', '/path/to/socket')

        mock_socket.return_value.send.assert_called_with(
            b'test\nOutputFormat: json\n')
    def test_should_write_query_to_socket(self):
        livestatus_service.livestatus.format_answer = lambda _, x, __: x

        mock_socket = mock()
        when(mock_socket).recv(any_value()).thenReturn(b'{}').thenReturn(None)
        when(livestatus_service.livestatus.socket).socket(any_value(), any_value()).thenReturn(mock_socket)
        when(livestatus_service.livestatus).format_answer(any_value(), any_value(), any_value()).thenReturn(None)

        perform_query('test', '/path/to/socket')

        verify(mock_socket).send(b'test\nOutputFormat: json\n')
    def test_should_write_query_to_socket(self):
        livestatus_service.livestatus.format_answer = lambda _, x, __: x

        mock_socket = mock()
        when(mock_socket).recv(any_value()).thenReturn(b'{}').thenReturn(None)
        when(livestatus_service.livestatus.socket).socket(
            any_value(), any_value()).thenReturn(mock_socket)
        when(livestatus_service.livestatus).format_answer(
            any_value(), any_value(), any_value()).thenReturn(None)

        perform_query('test', '/path/to/socket')

        verify(mock_socket).send(b'test\nOutputFormat: json\n')
    def test_should_read_query_answer_fully(self):
        mock_socket = mock()
        when(mock_socket).recv(any_value()).thenReturn(b'{}').thenReturn(None)
        when(livestatus_service.livestatus.socket).socket(any_value(), any_value()).thenReturn(mock_socket)
        when(livestatus_service.livestatus).format_answer(any_value(), any_value(), any_value()).thenReturn(None)
        livestatus_service.livestatus.format_answer = lambda _, x, __: x

        self.assertEqual(perform_query('test', '/path/to/socket'), '{}')
    def test_should_read_query_answer_fully(self):
        mock_socket = mock()
        when(mock_socket).recv(any_value()).thenReturn(b'{}').thenReturn(None)
        when(livestatus_service.livestatus.socket).socket(
            any_value(), any_value()).thenReturn(mock_socket)
        when(livestatus_service.livestatus).format_answer(
            any_value(), any_value(), any_value()).thenReturn(None)
        livestatus_service.livestatus.format_answer = lambda _, x, __: x

        self.assertEqual(perform_query('test', '/path/to/socket'), '{}')
    def test_should_read_query_answer_fully(self, mock_socket, format_answer):
        mock_socket.return_value.recv.side_effect = [b"{}", None]
        format_answer.side_effect = lambda _, x, __: x

        self.assertEqual(perform_query("test", "/path/to/socket"), "{}")
示例#8
0
    def test_should_read_query_answer_fully(self, mock_socket, format_answer):
        mock_socket.return_value.recv.side_effect = [b'{}', None]
        format_answer.side_effect = lambda _, x, __: x

        self.assertEqual(perform_query('test', '/path/to/socket'), '{}')
    def test_should_read_query_answer_fully(self, mock_socket, format_answer):
        mock_socket.return_value.recv.side_effect = [b'{}', None]
        format_answer.side_effect = lambda _, x, __: x

        self.assertEqual(perform_query('test', '/path/to/socket'), '{}')