automatically setups a elasticsearch instance in a temporary directory, and destroys it after testing
Project description
About
testing.elasticsearch automatically setups a elasticsearch instance in a temporary directory, and destroys it after testing.
Install
Use pip:
$ pip install testing.elasticsearch2
And testing.elasticsearch2 requires Elasticsearch server in your PATH.
Usage
Create Elasticsearch instance using testing.elasticsearch.Elasticsearch:
import testing.elasticsearch from sqlalchemy import create_engine # Lanuch new Elasticsearch server with testing.elasticsearch.Elasticsearch() as elasticsearch: # connect to Elasticsearch (using elasticsearch-py) es = Elasticsearch(**elasticsearch.dsn()) # # do any tests using Elasticsearch... # # Elasticsearch server is terminated here
testing.elasticsearch.Elasticsearch generates temporary config files and data directories. On deleting Elasticsearch object, it terminates Elasticsearch instance and removes temporary files and directories.
If you want a database including indexes and any fixtures for your apps, use copy_data_from keyword:
# uses a copy of specified data directory of Elasticsearch. elasticsearch = testing.elasticsearch.Elasticsearch(copy_data_from='/path/to/your/index')
For example, you can setup new Elasticsearch server for each testcases on setUp() method:
import unittest import testing.elasticsearch class MyTestCase(unittest.TestCase): def setUp(self): self.elasticsearch = testing.elasticsearch.Elasticsearch() def tearDown(self): self.elasticsearch.stop()
Requirements
Python 2.6, 2.7, 3.2, 3.3, 3.4, 3.5
License
Apache License 2.0
History
0.9.1 (2016-02-04)
Depend on testing.common.database package
0.9.0 (2015-12-13)
First release
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 Distribution
File details
Details for the file testing.elasticsearch2-0.9.1.tar.gz
.
File metadata
- Download URL: testing.elasticsearch2-0.9.1.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd03ec03974b35e2687622289a90d3081359075e5f9fdf912afa3f925c08da17 |
|
MD5 | 81f092ebdc33e4060e5faf6a03cb2104 |
|
BLAKE2b-256 | 7388153afaeec3238e15d4481c2273e16fe29b94cb7396a97b7f411b31090b77 |
File details
Details for the file testing.elasticsearch2-0.9.1-py2.py3-none-any.whl
.
File metadata
- Download URL: testing.elasticsearch2-0.9.1-py2.py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ebaeb2dabb34346a3cbe017d4d52c1da98820118645f4a39dd8f5212ccfe477 |
|
MD5 | cfa7e080802a264802c7c2232e964919 |
|
BLAKE2b-256 | b481e82100120de591539e0498867bf3d3c92f0f119278fa54074aff2a2b6fc4 |