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.7, 3.3, 3.4, 3.5

License

Apache License 2.0

History

1.0.0 (2016-08-20)

  • Drop python 2.6, 3.2 support

  • Depend on testing.common.database >= 2.0.0

  • Set booting timeout to 20sec

  • Fix bugs:

    • #1: find_elasticsearch_yaml_path() does not refer elasticsearch_home argument

    • #2: Make ES_PATH absolute

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

Uploaded Source

Built Distribution

testing.elasticsearch2-1.0.0-py2.py3-none-any.whl (7.3 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for testing.elasticsearch2-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c085e64251c9df88191e556d5ba43816f6bfa44dcc3ac37f8fdecbf07caee593
MD5 ab66adf329aae5ea0724db060ed94ac7
BLAKE2b-256 67ca3172ca5eb5ac8f0f1533f76024acebef1204258649be5f1e19f47f4a6162

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for testing.elasticsearch2-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2d31e1e702b034b79bafa652d1d254958ea5f1dbb3adb035ddadef26f0615f93
MD5 ae3bdf839521468c50c9ebb191c4d9e6
BLAKE2b-256 c4826378ee5d9c5041e495a565282a3477c58a0002d0527a657fc5353c2df320

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