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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for testing.elasticsearch-0.2.2.macosx-10.10-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f38e5e77e7f6a915c026dd2fde2b7786fadde267ea62ad9e78d0d2bd6f8074ef |
|
MD5 | 3ae3d77e0986820dbcb91fcee991265b |
|
BLAKE2b-256 | af038ec384f4385b74f8ef80a46dc69d19cf39a1bd28e29b082315777fd5975d |