Does anyone have experience with the ElasticMock python module?

Viewed 548

I am trying to integrate the ElasticMock python module into my unit testing, but I am having a hard time using it along with methods I have already created in my code.

import datetime
from elasticmock import elasticmock
from elasticmock.fake_elasticsearch import FakeElasticsearch


function test_me(self):
    doc = {
        'author': 'test_author',
        'text': 'Elasticsearch: cool. bonsai cool.',
        'timestamp': datetime.datetime.now()
    }

    fake_elasticsearch = FakeElasticsearch()
    f_index = fake_elasticsearch.index(index='test_index', doc_type='_doc', body=doc, id=1)
self.assertIsNotNone(r_index)

I expect when using the actual Elasticsearch module's get() method that I will be able to retrieve this index, and its contents from the local host unless this has nothing to do with the local host, and just spawns the index in memory during runtime.

0 Answers
Related