用于测试ElasticSearch查询的实用程序

ESTester的Python项目详细描述


estester是一个python包,用于帮助测试elasticsearch查询。

它提供了一个测试用例,允许您将数据加载到测试索引 并验证搜索查询的行为。

如何安装

使用pip从cheeseshop安装

pip install estester

或者,从源安装

git clone git://github.com/tatiana/estester.git
python setup.py install

如何使用

Estester定义了一个主测试类,称为ElasticSearchQueryTestCase。

为了使用它,您应该对它进行子类化并重新定义一个或多个类属性:

  • index:索引的名称(默认值:sample.test)
  • 主机:elasticsearch主机(默认值:http://localhost:9200/
  • fixtures:要加载的项目列表(默认值:[])
  • 超时:等待索引加载的时间(秒)(默认值:5s)
  • 重置索引:运行测试后删除索引(默认值:true)

基本示例,仅重新定义装置:

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,并且它已启动:
设置 进行测试

兼容性

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 <http://www.gnu.org/licenses/>.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java无法在未设置数据源的情况下启动springboot应用程序   返回/泛型的类型?   java通过在navigationView中按id重新加载navigationView内容   java实现安卓的状态更新   java Equals()对于两个相等的字符串不返回true   java如何保存屏幕截图(matlab)   java GWT如何在重新加载页面之前确保函数已完全执行   java在Groovy中实现ObjectJSON映射的标准方法是什么?   java在ApacheTomcat中,是否可以通过连接器过滤多个访问日志文件?   java当JVM达到其Xmx限制时,它会强制垃圾收集吗?   如何在JAVA中生成包含特定数字的不同随机数列表?   rcp中透视图之间的java切换   java理解名为“分区”的Linkedlist算法中的无限循环   RestTemplate的java测微计统计信息   Android中使用自定义服务BLE的java读/写特性   java验证输入以确保负数   关于Java扫描器的io基本查询   java如何使用子字符串或其他函数将字符串拆分为单词?   java Storm群集重复元组