Automatically sets up an elasticsearch instance in a temporary directory, and destroys it after testing
Project description
testing.elasticsearch
=====================
`testing.elasticsearch` automatically sets up an elasticsearch instance in a
temporary directory, and destroys it after testing. It's useful as a pytest
fixture for testing interactions with elasticsearch in an isolated manner.
Implementation is based off the awesome [testing.redis](https://bitbucket.org/tk0miya/testing.redis) module.
Example usage:
import testing.elasticsearch
import pyes.es import ES
# launch new elasticsearch server:
with testing.elasticsearch.ElasticSearchServer() es:
elasticsearch = ES(es.dsn())
# perform any testing with elasticsearch here
# elasticsearch server is terminated and cleaned up here
You can also setup a pytest fixture:
@pytest.fixture(scope='session')
def elasticsearch(request):
"""
A testing fixture that provides a running elasticsearch server.
"""
es = ElasticSearchServer()
es.start()
request.addfinalizer(es.stop)
return es
Testing
-------
To run tests you'll need to install the test requirements:
pip install -r src/tests/requirements.txt
Run tests:
python src/tests/runtests.py
=====================
`testing.elasticsearch` automatically sets up an elasticsearch instance in a
temporary directory, and destroys it after testing. It's useful as a pytest
fixture for testing interactions with elasticsearch in an isolated manner.
Implementation is based off the awesome [testing.redis](https://bitbucket.org/tk0miya/testing.redis) module.
Example usage:
import testing.elasticsearch
import pyes.es import ES
# launch new elasticsearch server:
with testing.elasticsearch.ElasticSearchServer() es:
elasticsearch = ES(es.dsn())
# perform any testing with elasticsearch here
# elasticsearch server is terminated and cleaned up here
You can also setup a pytest fixture:
@pytest.fixture(scope='session')
def elasticsearch(request):
"""
A testing fixture that provides a running elasticsearch server.
"""
es = ElasticSearchServer()
es.start()
request.addfinalizer(es.stop)
return es
Testing
-------
To run tests you'll need to install the test requirements:
pip install -r src/tests/requirements.txt
Run tests:
python src/tests/runtests.py
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
Built Distribution
Close
Hashes for testing.elasticsearch-0.2.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a69872c0fda7079ef7e25de88ab900d59dda9a79f39f5782fcf95c0182de973 |
|
MD5 | 11a477bcefa1930e832c92bcba9eb473 |
|
BLAKE2b-256 | 5fbab2a0f48f5818bd45439c7291f53542da607a704cd864094f666cc34e9ea9 |
Close
Hashes for testing.elasticsearch-0.2.3.macosx-10.10-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 730e5bbfd77c15301aea0e1189e7edbfc475eccf1b270ce00882a2fbc1f73fdb |
|
MD5 | f9190844974d92fb2811a7d29e76510b |
|
BLAKE2b-256 | 9a6c98e3befba966025f8681f6830bc6798f2a2b6bfdc5e4c8985e355add2a64 |