Skip to main content

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.

https://travis-ci.org/tk0miya/testing.elasticsearch.svg?branch=master https://coveralls.io/repos/tk0miya/testing.elasticsearch/badge.png?branch=master https://codeclimate.com/github/tk0miya/testing.elasticsearch/badges/gpa.svg

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


Download files

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

Source Distribution

testing.elasticsearch2-0.9.1.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

testing.elasticsearch2-0.9.1-py2.py3-none-any.whl (7.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file testing.elasticsearch2-0.9.1.tar.gz.

File metadata

File hashes

Hashes for testing.elasticsearch2-0.9.1.tar.gz
Algorithm Hash digest
SHA256 bd03ec03974b35e2687622289a90d3081359075e5f9fdf912afa3f925c08da17
MD5 81f092ebdc33e4060e5faf6a03cb2104
BLAKE2b-256 7388153afaeec3238e15d4481c2273e16fe29b94cb7396a97b7f411b31090b77

See more details on using hashes here.

File details

Details for the file testing.elasticsearch2-0.9.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for testing.elasticsearch2-0.9.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5ebaeb2dabb34346a3cbe017d4d52c1da98820118645f4a39dd8f5212ccfe477
MD5 cfa7e080802a264802c7c2232e964919
BLAKE2b-256 b481e82100120de591539e0498867bf3d3c92f0f119278fa54074aff2a2b6fc4

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