Skip to content

Commit

Permalink
Migrated test_[cluster,dump_curl,facets] to python3
Browse files Browse the repository at this point in the history
  • Loading branch information
aparo committed Jan 4, 2014
1 parent acd9122 commit 97fe742
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pyes/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ def collect_info(self):
info['server']['name'] = res['name']
info['server']['version'] = res['version']
info['allinfo'] = res
info['status'] = self.status()
info['aliases'] = self.aliases()
info['status'] = self.cluster.status()
info['aliases'] = self.indices.aliases()
self.info = info
return True
except:
Expand Down
6 changes: 5 additions & 1 deletion tests/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_ClusterState(self):
self.assertTrue('routing_table' in result)

def test_ClusterNodes(self):
result = self.conn.cluster.nodes()
result = self.conn.cluster.nodes_info()
self.assertTrue('cluster_name' in result)
self.assertTrue('nodes' in result)

Expand All @@ -66,3 +66,7 @@ def test_ClusterHealth(self):
timeout=0, wait_for_status='green')
# There shouldn't be any active shards on this index
self.assertEqual(result['active_shards'], 0)

if __name__ == "__main__":
import unittest
unittest.main()
10 changes: 7 additions & 3 deletions tests/test_dump_curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
from __future__ import absolute_import
import unittest
from pyes.tests import ESTestCase, get_conn
import StringIO
import six
if six.PY2:
from io import StringIO
else:
from io import BytesIO as StringIO

class DumpCurlTestCase(ESTestCase):
def setUp(self):
Expand All @@ -12,12 +16,12 @@ def testDumpCurl(self):
"""Test errors thrown when creating or deleting indices.
"""
dump = StringIO.StringIO()
dump = StringIO()
conn = get_conn(dump_curl=dump)
result = conn.index(dict(title="Hi"), self.index_name, self.document_type)
self.assertTrue('ok' in result)
self.assertTrue('error' not in result)
dump = dump.getvalue()
dump = dump.getvalue().decode("utf-8")
self.assertTrue("""
curl -XPOST 'http://127.0.0.1:9200/test-index/test-type?pretty=true' -d '{"title": "Hi"}'
""".strip() in dump)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_facets.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_terms_facet(self):
q4 = MatchAllQuery()
q4 = q4.search()
q4.facet.add_term_facet('bag')
self.assertNotEquals(q2, q4)
self.assertNotEqual(q2, q4)

def test_terms_facet_filter(self):
q = MatchAllQuery()
Expand All @@ -107,7 +107,7 @@ def test_terms_facet_filter(self):
q4 = FilteredQuery(q4, TermFilter('tag', 'foo'))
q4 = q4.search()
q4.facet.add_term_facet('bag')
self.assertNotEquals(q3, q4)
self.assertNotEqual(q3, q4)

def test_date_facet(self):
q = MatchAllQuery()
Expand All @@ -120,9 +120,9 @@ def test_date_facet(self):
self.assertEqual(resultset.facets.date_facet.entries, [{u'count': 2, u'time': 1301616000000},
{u'count': 1, u'time': 1304208000000}])
self.assertEqual(datetime.datetime.utcfromtimestamp(1301616000000 / 1000.).date(),
datetime.date(2011, 04, 01))
datetime.date(2011, 4, 1))
self.assertEqual(datetime.datetime.utcfromtimestamp(1304208000000 / 1000.).date(),
datetime.date(2011, 05, 01))
datetime.date(2011, 5, 1))

def test_date_facet_filter(self):
q = MatchAllQuery()
Expand Down

0 comments on commit 97fe742

Please sign in to comment.