ElasticSearch查询测试工具
项目描述
ESTester是一个Python包,用于帮助测试ElasticSearch查询。
它提供了一个TestCase,允许您将数据加载到测试索引中并验证搜索查询的行为。
如何安装
使用pip从Cheeseshop安装
pip install estester
或者,从源安装
git clone git://github.com/tatiana/estester.git python setup.py install
如何使用
ESTester定义了一个主要测试类,称为ElasticSearchQueryTestCase。
为了使用它,您应该从它派生一个子类并重新定义一个或多个类属性
index:索引的名称(默认:sample.test)
host:ElasticSearch主机(默认:http://localhost:9200/)
fixtures:要加载的项目列表(默认:[])
timeout:等待索引加载的时间(秒)(默认:5s)
reset_index:在运行测试后删除索引(默认:True)
基本示例,仅重新定义fixtures
from estester import ElasticSearchQueryTestCase SAMPLE_QUERY = { "query": { "query_string": { "fields": [ "name" ], "query": "nina" } } } class QueryTestCase(ElasticSearchQueryTestCase): fixtures = [ { "type": "dog", "id": "1", "body": {"name": "Nina Fox"} }, { "type": "dog", "id": "2", "body": {"name": "Charles M."} } ] def test_query_by_nina_returns_one_result(self): response = self.query(SAMPLE_QUERY) self.assertEqual(response["hits"]["total"], 1) self.assertEqual(response["hits"]["hits"][0]["_id"], u"1") self.assertEqual(response["hits"]["hits"][0]["_source"], {u"name": u"Nina Fox"})
ESTester测试
- 为了运行ESTester测试,请确保您已在本地上安装ElasticSearch并且它已启动:
make setup make test
兼容性
ESTester已被成功用于测试ElasticSearch 19.x和90.x版本的查询。
有关此令人惊叹的开源搜索引擎的更多信息,请参阅:http://www.elasticsearch.org/
许可协议
ESTester是GNU GPL 2
< ESTester: ElasticSearch Tester > Copyright (C) 2013 - Tatiana Al-Chueyr Pereira Martins ESTester is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2 of the License. ESTester is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ESTester. If not, see <https://gnu.ac.cn/licenses/>.
项目详情
关闭
ESTester-1.1.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 22b1c5406273c871a3cfe4746e54c55bfb67ed1c8d7c2d5d28990066e398d63b |
|
MD5 | c7c4bec129045648a8b95ec9ba911de3 |
|
BLAKE2b-256 | e9117964e0e30e0e2f318108b029c03ac6f5556f33e74b89a8efc1852c7dd652 |