Exemplo n.º 1
0
    def test_ensure_server_defaults_not_exists(self):
        """Assert raise when the argument given is not a configured server."""
        servers = {}
        indices = {}

        handler = ConnectionHandler(servers, indices)

        with self.assertRaises(ConnectionDoesNotExist) as raised:
            handler.ensure_server_defaults('index')

        assert str(raised.exception) == '%r' % 'index'
Exemplo n.º 2
0
    def test_ensure_server_defaults_not_exists(self):
        """Assert raise when the argument given is not a configured server."""
        servers = {}
        indices = {}

        handler = ConnectionHandler(servers, indices)

        with self.assertRaises(ConnectionDoesNotExist) as raised:
            handler.ensure_server_defaults('index')

        assert str(raised.exception) == '%r' % 'index'
Exemplo n.º 3
0
    def test_empty_ensure_server_defaults(self):
        """Assert default values are set properly on an empty server."""
        handler = ConnectionHandler({}, {})
        handler.ensure_server_defaults('default')

        default_server = handler.servers['default']

        expected_server = {
            'ENGINE': 'djangoes.backends.elasticsearch.SimpleHttpBackend',
            'HOSTS': [],
            'PARAMS': {},
            'INDICES': []
        }

        assert default_server == expected_server
Exemplo n.º 4
0
    def test_empty_ensure_server_defaults(self):
        """Assert default values are set properly on an empty server."""
        handler = ConnectionHandler({}, {})
        handler.ensure_server_defaults('default')

        default_server = handler.servers['default']

        expected_server = {
            'ENGINE': 'djangoes.backends.elasticsearch.SimpleHttpBackend',
            'HOSTS': [],
            'PARAMS': {},
            'INDICES': []
        }

        assert default_server == expected_server