Code Monkey home page Code Monkey logo

grofers / pytest-elasticsearch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from clearcodehq/pytest-elasticsearch

0.0 6.0 0.0 128 KB

This is a pytest plugin that enables you to test your code that relies on a running Elasticsearch search engine. It allows you to specify fixtures for Elasticsearch process and client.

Home Page: https://pypi.python.org/pypi/pytest-elasticsearch/

License: GNU Lesser General Public License v3.0

Python 100.00%

pytest-elasticsearch's Introduction

pytest-elasticsearch

Latest PyPI version Wheel Status Supported Python Versions License

Package status

Tests Coverage Status Requirements Status

What is this?

This is a pytest plugin that enables you to test your code that relies on a running Elasticsearch search engine. It allows you to specify fixtures for Elasticsearch process and client.

How to use

Warning

This fixture requires at least version 1.0 of elasticsearch to work.

The plugin contains two fixtures:

  • elasticsearch - a client fixture that has functional scope, and which cleans Elasticsearch at the end of each test.
  • elasticsearch_proc - a session scoped fixture, that starts Elasticsearch instance at its first use and stops at the end of the tests.

Simply include one of these fixtures into your tests fixture list.

You can also create additional elasticsearch client and process fixtures if you'd need to:

from pytest_elasticsearch import factories

elasticsearch_my_proc = factories.elasticsearch_proc(
    port=None, logsdir='/tmp')
elasticsearch_my = factories.elasticsearch('elasticsearch_my_proc')

Note

Each elasticsearch process fixture can be configured in a different way than the others through the fixture factory arguments.

Configuration

You can define your settings in three ways, it's fixture factory argument, command line option and pytest.ini configuration option. You can pick which you prefer, but remember that these settings are handled in the following order:

  1. Fixture factory argument
  2. Command line option
  3. Configuration option in your pytest.ini file
Elasticsearch option Fixture factory argument Command line option pytest.ini option Default
logs directory logsdir --elasticsearch-logsdir elasticsearch_logsdir $TMPDIR
host host --elasticsearch-host elasticsearch_host 127.0.0.1
port port --elasticsearch-port elasticsearch_port random
cluster_name cluster_name --elasticsearch-cluster-name elasticsearch_cluster_name elasticsearch_cluster_<port>
index store type index_store_type --elasticsearch-index-store-type elasticsearch_index_store_type memory
network publish host network_publish_host --elasticsearch-network-publish-host elasticsearch_network_publish_host 127.0.0.1
logs prefix logs_prefix --elasticsearch-logs-prefix elasticsearch_logs_prefix ย 
enable zen discovery discovery_zen_ping_multicast_enabled --elasticsearch-discovery-zen-ping-multicast-enabled elasticsearch_discovery_zen_ping_multicast_enabled False
default.conf.path conf_path --elasticsearch-conf-path elasticsearch_conf_path /etc/elasticsearch

Example usage:

  • pass it as an argument in your own fixture

    elasticsearch_proc = factories.elasticsearch_proc(
        cluster_name='awsome_cluster)
  • use --elasticsearch-logsdir command line option when you run your tests

    py.test tests --elasticsearch-cluster-name=awsome_cluster
    
  • specify your directory as elasticsearch_cluster_name in your pytest.ini file.

    To do so, put a line like the following under the [pytest] section of your pytest.ini:

    [pytest]
    elasticsearch_cluster_name = awsome_cluster

Package resources

pytest-elasticsearch's People

Contributors

fizyk avatar kblumke avatar mmaslowskicc avatar quantifiedcode-bot avatar requires avatar yashmehrotra avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.