Elasticsearch process and client fixtures for py.test.
Project description
pytest-elasticsearch
Package status
What is this?
This is a pytest plugin, that enables you test your code that relies on an 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.
You can set and run elasticsearch process with your own settings (i.e. use random port or define your own logsdir)
elasticsearch_proc = factories.elasticsearch_proc(
port=None, logsdir='/tmp')
You can use elasticsearch client fixture to run your test. (Remember that client fixture requires a process fixture to work properly.)
elasticsearch = factories.elasticsearch(elasticsearch_proc)
To check if everything is ready to go, you can always test both fixtures:
def test_elastic_process(elasticsearch_proc):
"""Simple test for starting elasticsearch_proc."""
assert elasticsearch_proc.running() is True
def test_elasticsarch(elasticsearch):
"""Tests if elasticsearch fixtures connects to process."""
info = elasticsearch.info()
assert info['status'] == 200
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 |
Configuration option in pytest.ini |
Default |
---|---|---|---|---|
logs directory |
logsdir |
–elasticsearch-logsdir |
elasticsearch_logsdir |
/tmp |
host |
host |
–elasticsearch-host |
elasticsearch_host |
127.0.0.1 |
port |
port |
–elasticsearch-port |
elasticsearch_port |
9201 |
cluster_name |
cluster_name |
–elasticsearch-cluster-name |
elasticsearch_cluster_name |
elasticsearch_cluster_9201 |
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 |
|
discovery en ping multicast enabled |
discovery_zen_ping_multicast_enabled |
–elasticsearch-discovery-zen-ping-multicast-enabled |
elasticsearch_discovery_zen_ping_multicast_enabled |
False |
Example of use: logs directory:
pass it as an argument in your own fixture
elasticsearch_proc = factories.elasticsearch_proc( logsdir='/tmp')
use --elasticsearch-logsdir command line option when you run your tests
py.test tests --elasticsearch-logsdir=/tmp
specify your directory as logsdir in your pytest.ini file.
To do so, put a line like the following under the [pytest] section of your pytest.ini:
[pytest] elasticsearch_logsdir = /tmp/elasticsearch/logs
If you don’t want to define your own settings in any given way, you can always use a default values.
Package resources
Bug tracker: https://github.com/ClearcodeHQ/pytest_elasticsearch/issues
Documentation: http://pytest_elasticsearch.readthedocs.org/
Travis-ci
After creating package on github, move to tracis-ci.org, and turn on ci builds for given package.
CHANGELOG
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pytest-elasticsearch-1.0.0.tar.gz
.
File metadata
- Download URL: pytest-elasticsearch-1.0.0.tar.gz
- Upload date:
- Size: 30.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d37b5e45cbc13bd26023276e3492999a1a101a109bef0b9138887b7d202227d5 |
|
MD5 | 995b007cc3c3881a85ae9b951f66087c |
|
BLAKE2b-256 | 7f51e72998fda6213c84b3fd0e928c5467ece11101b471c950171f47bbb154b2 |
File details
Details for the file pytest_elasticsearch-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pytest_elasticsearch-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e60adbadc3db16b444399992f29dbeae2a5da173485d383b6041e6469985c29 |
|
MD5 | 80bc2586f9684c1618f84dff3dcbfccf |
|
BLAKE2b-256 | 552844ebd69577d0e336ed472478289984a7ae139cbfc7adc18a838271453e60 |
File details
Details for the file pytest_elasticsearch-1.0.0-py2.7.egg
.
File metadata
- Download URL: pytest_elasticsearch-1.0.0-py2.7.egg
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9f4c2b7b1fbc4059d9c3b77a568015f3c85aae47ea77d8727ff459493bbd9d0 |
|
MD5 | 1eb0d20b761bdde7661904163eff6beb |
|
BLAKE2b-256 | a3ef2d055293d03bae11454d40d1ea227a022d078792eac796401032486d568c |