This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

This package provides a elasticsearch server stub setup based on a real elasticsearch server.

README

setup

This test is using an elasticsearch server. The test setUp method used for this test is calling our startElasticSearchServer method which is starting an elasticsearch server. The first time this test get called a new elasticsearch server will get downloaded. The test setup looks like:

def test_suite():
    return unittest.TestSuite((
        doctest.DocFileSuite('README.txt',
            setUp=testing.doctestSetUp, tearDown=testing.doctestTearDown,
            optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
            encoding='utf-8'),
        ))

If you like to set some custom settings, you can use the confSource which must point to a config folder with elasticsearch.yml or elasticsearch.json and logging.yml and optional mapping definitions. Your custom doctest setUp and tearDown method could look like:

def mySetUp(test):
    # use default elasticsearch with our server and conf source dir
    here = os.path.dirname(__file__)
    serverDir = os.path.join(here, 'server')
    confSource = os.path.join(here, 'config')
    p01.elasticstub.testing.startElasticSearchServer(serverDir=serverDir,
        confSource=confSource)

def myTearDown(test):
    p01.elasticstub.testing.stopElasticSearchServer()
    # do some custom teardown stuff here

testing

Let’s setup a python httplib connection:

>>> import httplib
>>> conn = httplib.HTTPConnection('localhost', 45200)

and test the cluster state:

>>> conn.request('GET', '_cluster/state')
>>> response = conn.getresponse()
>>> response.status
200
>>> import json
>>> from pprint import pprint
>>> body = response.read()
>>> pprint(json.loads(body))
{u'allocations': [],
 u'blocks': {},
 u'cluster_name': u'p01_elasticstub_testing',
 u'master_node': u'...',
 u'metadata': {u'indices': {}, u'templates': {}},
 u'nodes': {u'...': {u'attributes': {},
                                        u'name': u'...',
                                        u'transport_address': u'inet[...]'}},
 u'routing_nodes': {u'nodes': {u'...': []},
                    u'unassigned': []},
 u'routing_table': {u'indices': {}},
 u'version': 3}

As you can see our mapping is empty:

>>> conn.request('GET', '/testing/test/_mapping')
>>> response = conn.getresponse()
>>> body = response.read()
>>> pprint(json.loads(body))
{u'error': u'IndexMissingException[[testing] missing]', u'status': 404}

Let’s index a simple item:

>>> body = json.dumps({u'title': u'Title'})
>>> conn.request('POST', '/testing/test/1', body)
>>> response = conn.getresponse()
>>> body = response.read()
>>> pprint(json.loads(body))
{u'_id': u'1',
 u'_index': u'testing',
 u'_type': u'test',
 u'_version': 1,
 u'created': True}

refresh:

>>> conn.request('GET', '/testing/test/_refresh')
>>> response = conn.getresponse()
>>> body = response.read()
>>> pprint(json.loads(body))
{u'_id': u'_refresh',
 u'_index': u'testing',
 u'_type': u'test',
 u'found': False}

Let’s set a mapping:

>>> body = json.dumps({'test': {'properties': {'title': {'type': 'string'}}}})
>>> conn.request('POST', '/testing/test/_mapping', body)
>>> response = conn.getresponse()
>>> body = response.read()
>>> pprint(json.loads(body))
{u'acknowledged': True}

and test our mapping again:

>>> conn.request('GET', '/testing/test/_mapping')
>>> response = conn.getresponse()
>>> body = response.read()
>>> pprint(json.loads(body))
{u'testing': {u'mappings': {u'test': {u'properties': {u'title': {u'type': u'string'}}}}}}

CHANGES

0.5.3 (2014-07-10)

  • switch to elasticsearch version 1.2.1. Note; version 1.2.2 does not work at least on windows. Startup quits with en error like {1.2.2}: Initialization Failed … ExecutionError[java.lang.IncompatibleClassChangeError: Implementing class] IncompatibleClassChangeError[Implementing class]

0.5.2 (2012-12-22)

  • switch to elasticsearch 0.20.1. Note; there is no need to switch to newer releases just for get the latest version. Simply use the downloadURL attribute for set a newer elasticsearch version download url
  • It seems that the auto mapping doesn’t work anymore by default. Added explicit mapping setup after inserting first item. This seems to wrk as it should.
  • bugfix: adjust base url, if used with version, from git to elasticsearch

0.5.1 (2012-12-10)

  • switch to elasticsearch 0.20.0
  • added version argument to startElasticSearchServer
  • cleanup imports

0.5.0 (2012-11-18)

  • initial release tested on win 32bit and posix 32bit. NOT tested on win 64bit, posix 64bit and mac 32/64bit systems.
Release History

Release History

0.5.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
p01.elasticstub-0.5.3.zip (30.6 kB) Copy SHA256 Checksum SHA256 Source Jul 10, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting