summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2015-02-13 18:24:18 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2015-02-13 18:24:18 -0800
commit1a54d04a424ce5e8a6129957e9ceadd8d7b7b6b1 (patch)
tree40596cd3ea9aeb9d2f0eec08aa426c55efdfe5b8
parent2128c1653110fb7f3f518e84d16e7723ceb695e9 (diff)
downloadzake-1a54d04a424ce5e8a6129957e9ceadd8d7b7b6b1.tar.gz
Ensure commands are always byte strings
-rw-r--r--zake/fake_client.py8
-rw-r--r--zake/tests/test_client.py8
2 files changed, 8 insertions, 8 deletions
diff --git a/zake/fake_client.py b/zake/fake_client.py
index d5554d0..5ae9cf2 100644
--- a/zake/fake_client.py
+++ b/zake/fake_client.py
@@ -122,16 +122,16 @@ class FakeClient(object):
def command(self, cmd=b'ruok'):
self.verify()
- if cmd == 'ruok':
+ if cmd == b'ruok':
return 'imok'
- if cmd == 'stat':
+ if cmd == b'stat':
server_version = ".".join([str(s) for s in self._server_version])
return "\n".join(['Zake the fake version: %s' % (version.VERSION),
'Mimicked version: %s' % (server_version),
'Mode: standalone'])
- if cmd == "kill":
+ if cmd == b"kill":
self.stop()
- if cmd == 'envi':
+ if cmd == b'envi':
server_version = ".".join([str(s) for s in self._server_version])
lines = [
"Environment:",
diff --git a/zake/tests/test_client.py b/zake/tests/test_client.py
index 44e0acd..3329cd9 100644
--- a/zake/tests/test_client.py
+++ b/zake/tests/test_client.py
@@ -76,20 +76,20 @@ class TestClient(test.Test):
def test_command(self):
with start_close(self.client) as c:
self.assertTrue(c.connected)
- self.assertEqual("imok", c.command('ruok'))
+ self.assertEqual(b"imok", c.command(b'ruok'))
self.client.command('kill')
self.assertFalse(c.connected)
def test_command_version(self):
with start_close(self.client) as c:
- stats = c.command('stat')
+ stats = c.command(b'stat')
self.assertIn("standalone", stats)
version = ".".join([str(s) for s in fake_client.SERVER_VERSION])
self.assertIn(version, stats)
def test_command_envi(self):
with start_close(self.client) as c:
- envi = c.command('envi')
+ envi = c.command(b'envi')
self.assertIn("zookeeper.version", envi)
version = ".".join([str(s) for s in fake_client.SERVER_VERSION])
self.assertIn(version, envi)
@@ -101,7 +101,7 @@ class TestClient(test.Test):
def test_command_custom_version(self):
client = fake_client.FakeClient(server_version=(1, 1, 1))
with start_close(client) as c:
- stats = c.command('stat')
+ stats = c.command(b'stat')
self.assertIn("standalone", stats)
self.assertIn('1.1.1', stats)