示例#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
文件: client_test.py 项目: yumatch/h
    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)