Skip to content

Commit

Permalink
Merge pull request #862 from cp2587/master
Browse files Browse the repository at this point in the history
use isinstance instead of type() in verify_client_object
  • Loading branch information
untergeek committed Jan 4, 2017
2 parents 1792db1 + bb3c152 commit 46224d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion curator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def verify_client_object(test):
if str(type(test)) == "<class 'mock.Mock'>" or \
str(type(test)) == "<class 'mock.mock.Mock'>":
pass
elif not type(test) == type(elasticsearch.Elasticsearch()):
elif not isinstance(test, elasticsearch.Elasticsearch):
raise TypeError(
'Not a client object. Type: {0}'.format(type(test))
)
Expand Down
17 changes: 17 additions & 0 deletions test/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,3 +602,20 @@ def test_index_with_snapshot_filter(self):
'delete_indices',
[{'filtertype': 'state', 'state': 'SUCCESS'}]
)


class TestVerifyClientObject(TestCase):

def test_is_client_object(self):
test = elasticsearch.Elasticsearch()
self.assertIsNone(curator.verify_client_object(test))

def test_is_not_client_object(self):
test = 'not a client object'
self.assertRaises(TypeError, curator.verify_client_object, test)

def test_is_a_subclass_client_object(self):
class ElasticsearchSubClass(elasticsearch.Elasticsearch):
pass
test = ElasticsearchSubClass()
self.assertIsNone(curator.verify_client_object(test))

0 comments on commit 46224d2

Please sign in to comment.