Doesn't mock with elasticsearch 6.1.1
tovmeod opened this issue · 3 comments
I'm using elasticsearch 6.1.1, I'm aware that elastickmock needs elasticsearch==1.9.0
But I tried to use it anyway, it seems it is not able to even mock properly, my tests are still instantiating the Elasticsearch client.
I would suspect the patch changed from 'elasticsearch.Elasticsearch', but to use the client I still import like:
from elasticsearch import Elasticsearch
I'm using python 3.6
I had a similar issue - and I was able to workaround it via:
import elasticsearch
def __init__(self):
es = elasticsearch.Elasticsearch(hosts=[{'host': 'localhost', 'port': 9200}])
my work around is basically rewrite that wrapper
https://github.com/vrcmarcos/elasticmock/blob/master/elasticmock/__init__.py#L31
to something like this:
def test(self):
with patch('elasticsearch_dsl.connections.Elasticsearch', _get_elasticmock):
print connections.create_connection(hosts=[{'host': 'localhost', 'port': 100}])
you'll have to dig in where that from elasticsearch import Elasticsearch is define :/
Hi,
I just added TOX to build against all elasticsearch versions based on last release for each major version.
Now, we are covering different ES versions on our tests. If your error persists, please reopen this issue.
Thank you!