def test_perform_query_should_dispatch_to_livestatus_if_handler_is_livestatus(self, query, current_config): mock_config = Mock() mock_config.livestatus_socket = '/path/to/socket' current_config.return_value = mock_config perform_query('FOO;bar', None, 'livestatus') query.assert_called_with('FOO;bar', '/path/to/socket', None)
def test_perform_query_should_dispatch_to_livestatus_if_handler_is_livestatus( self, query, current_config): mock_config = Mock() mock_config.livestatus_socket = '/path/to/socket' current_config.return_value = mock_config perform_query('FOO;bar', None, 'livestatus') query.assert_called_with('FOO;bar', '/path/to/socket', None)
def test_perform_query_should_dispatch_to_livestatus_if_handler_is_livestatus(self): when(livestatus_service.dispatcher).perform_livestatus_query(any_value(), any_value(), any_value()).thenReturn(None) mock_config = mock() mock_config.livestatus_socket = '/path/to/socket' when(livestatus_service.dispatcher).get_current_configuration().thenReturn(mock_config) perform_query('FOO;bar', None, 'livestatus') verify(livestatus_service.dispatcher).perform_livestatus_query('FOO;bar', '/path/to/socket', None)
def test_perform_query_should_dispatch_to_livestatus_with_auth_none_if_admin_user(self, query, current_config): mock_config = Mock() mock_config.livestatus_socket = '/path/to/socket' mock_config.admins = ["admin"] current_config.return_value = mock_config perform_query('FOO;bar', key=None, handler='livestatus', auth="admin") query.assert_called_with('FOO;bar', '/path/to/socket', None, auth=None)
def test_perform_query_should_dispatch_to_livestatus_if_handler_is_livestatus_admin_default_is_none( self, query, current_config): mock_config = Mock() mock_config.livestatus_socket = '/path/to/socket' mock_config.admins = [] current_config.return_value = mock_config perform_query('FOO;bar', key=None, handler='livestatus') query.assert_called_with('FOO;bar', '/path/to/socket', None, auth=None)
def test_perform_query_should_dispatch_to_livestatus_if_handler_is_livestatus( self): when(livestatus_service.dispatcher).perform_livestatus_query( any_value(), any_value(), any_value()).thenReturn(None) mock_config = mock() mock_config.livestatus_socket = '/path/to/socket' when(livestatus_service.dispatcher).get_current_configuration( ).thenReturn(mock_config) perform_query('FOO;bar', None, 'livestatus') verify(livestatus_service.dispatcher).perform_livestatus_query( 'FOO;bar', '/path/to/socket', None)