Ejemplo n.º 1
0
    def test_it(self, Client, Elasticsearch, settings, expected):
        client = get_client(
            {"es.url": sentinel.url, "es.index": sentinel.index, **settings}
        )

        args, kwargs = Elasticsearch.call_args
        assert args, kwargs == (([sentinel.url],), Any.dict.containing(expected))

        Client.assert_called_once_with(
            index=sentinel.index, conn=Elasticsearch.return_value
        )
        assert client == Client.return_value
Ejemplo n.º 2
0
    def test_uses_es6_when_specified(self):
        client = Client(host="http://localhost:9200",
                        index="hypothesis",
                        elasticsearch=elasticsearch)

        assert client.version == (6, 2, 0)
        assert isinstance(client.conn, elasticsearch.Elasticsearch)
Ejemplo n.º 3
0
    def test_it_sets_the_index_property(self):
        client = Client(host="http://localhost:9200", index="hypothesis")

        assert client.index == "hypothesis"
Ejemplo n.º 4
0
    def test_conn_is_read_only(self):
        client = Client(host="http://localhost:9200", index="hypothesis")

        with pytest.raises(AttributeError, match="can't set attribute"):
            client.conn = "changed"
Ejemplo n.º 5
0
    def test_it_sets_the_conn_property(self):
        client = Client(host="http://localhost:9200", index="hypothesis")

        assert isinstance(client.conn, elasticsearch.Elasticsearch)
Ejemplo n.º 6
0
    def test_it_sets_the_version_property(self):
        client = Client(host="http://localhost:9200", index="hypothesis")

        assert client.version >= (6, 4, 0) and client.version < (7, 0, 0)
Ejemplo n.º 7
0
    def test_defaults_to_es1(self):
        client = Client(host="http://localhost:9200", index="hypothesis")

        assert isinstance(client.conn, elasticsearch1.Elasticsearch)
Ejemplo n.º 8
0
    def test_conn_is_read_only(self):
        client = Client(host="http://localhost:9200", index="hypothesis")

        with pytest.raises(AttributeError, match="can't set attribute"):
            client.conn = "changed"
Ejemplo n.º 9
0
 def client(self, conn):
     return Client(index=sentinel.index, conn=conn)