Skip to main content

Elasticsearch process and client fixtures for py.test.

Project description

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

Plugin contains two fixtures

  • elasticsearch - it’s a client fixture that has functional scope, and which cleans Elasticsearch at the end of each test.

  • elasticsearch_proc - session scoped fixture, that starts Elasticsearch instance at it’s 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')

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:

  • Fixture factory argument

  • Command line option

  • 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

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

CHANGELOG

1.2.1

  • [cleanup] - removed path.py dependency

1.2.0

  • [feature] - migrate usage of getfuncargvalue to getfixturevalue. require at least pytest 3.0.0

  • [feature] - default logsdir to $TMPDIR

  • [feature] - run process on random port by default - enhances xdist experience

1.1.0

  • [feature] use tmpfile.gettempdir instead of hardcoded /tmp directory

  • [docs] added description to all command line and ini options

  • [bugfix] made command line option’s dests more distinc, to prevent from influencing other pytest plugins

1.0.0

  • [feature] pytest.ini option for every command line option

  • [feature] Command line options for every fixture factory argument

  • Extracted original code from pytest-dbfixtures

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-elasticsearch-1.2.1.tar.gz (30.6 kB view details)

Uploaded Source

Built Distributions

pytest_elasticsearch-1.2.1-py2.py3-none-any.whl (12.6 kB view details)

Uploaded Python 2 Python 3

pytest_elasticsearch-1.2.1-py2.7.egg (15.1 kB view details)

Uploaded Source

File details

Details for the file pytest-elasticsearch-1.2.1.tar.gz.

File metadata

File hashes

Hashes for pytest-elasticsearch-1.2.1.tar.gz
Algorithm Hash digest
SHA256 d65c02deeca79edf891aa46bde42e675c1203e74bbb550ca4883dcd96c15f894
MD5 65165a87acec984d7da897a5d1e90666
BLAKE2b-256 51d816e7d24eac182e0f8c750a3b05e6e8064a06d8c7232832e7f80b910a9c77

See more details on using hashes here.

File details

Details for the file pytest_elasticsearch-1.2.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_elasticsearch-1.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e6913d45ba157c7baa8fe95da5c2f5073fdd10ee930e83763a18ca6d73f6be26
MD5 becf4b2999ca54d183f0d2cb81f0f182
BLAKE2b-256 5c6374fa48e365d3bb36d43ab36c49e0eb5d847e0856186e8da23e50ffad9e06

See more details on using hashes here.

File details

Details for the file pytest_elasticsearch-1.2.1-py2.7.egg.

File metadata

File hashes

Hashes for pytest_elasticsearch-1.2.1-py2.7.egg
Algorithm Hash digest
SHA256 5435f2794afbf3b0397a9af7348c1bea067febafce840a7bddba1e93d4f37336
MD5 11d2001e9b6ef2c63cf71481ffc7c4b3
BLAKE2b-256 968ce8ac782daeef3927d65466b5744b551f3589520d7384ee8122cf30fd4cb6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page