Пример #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
Пример #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)
Пример #3
0
    def test_it_sets_the_index_property(self):
        client = Client(host="http://localhost:9200", index="hypothesis")

        assert client.index == "hypothesis"
Пример #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"
Пример #5
0
    def test_it_sets_the_conn_property(self):
        client = Client(host="http://localhost:9200", index="hypothesis")

        assert isinstance(client.conn, elasticsearch.Elasticsearch)
Пример #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)
Пример #7
0
    def test_defaults_to_es1(self):
        client = Client(host="http://localhost:9200", index="hypothesis")

        assert isinstance(client.conn, elasticsearch1.Elasticsearch)
Пример #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"
Пример #9
0
 def client(self, conn):
     return Client(index=sentinel.index, conn=conn)