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.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.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

testing.elasticsearch2-0.9.0-py2.py3-none-any.whl (8.0 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for testing.elasticsearch2-0.9.0.tar.gz
Algorithm Hash digest
SHA256 54c064eb7d4783f49d472876e04cabf89d077b9ada80a2ce9eec54f13a69a751
MD5 e0d51d735e9163786fda229ffb49a294
BLAKE2b-256 76e544ba03bf9d9eca5813e2ec0a52da67544d1b9029d0dbcc41643fcfc18de6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for testing.elasticsearch2-0.9.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7be10e0ff46406609c5af474b2848dfbc99b6ca9b6bcee66ba0ebe404c1953dd
MD5 25d568e9d2ddf5711960ab96773b0f00
BLAKE2b-256 4ae409d7921b10c2a9d2beb4f61f49e064ea42d53be6c3e409c2fe02b483f264

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