add tests for py client

This commit is contained in:
holys 2014-09-03 23:01:10 +08:00
parent 210d51258b
commit 6f3f049707
2 changed files with 40 additions and 3 deletions

View File

@ -0,0 +1,7 @@
dbs=(leveldb rocksdb hyperleveldb goleveldb boltdb lmdb)
for db in "${dbs[@]}"
do
ledis-server -db_name=$db &
py.test
killall ledis-server
done

View File

@ -12,14 +12,44 @@ from util import expire_at, expire_at_seconds
l = ledis.Ledis(port=6380) l = ledis.Ledis(port=6380)
simple_script = "return {KEYS[1], KEYS[2], ARGV[1], ARGV[2]}"
class TestCmdScript(unittest.TestCase): class TestCmdScript(unittest.TestCase):
def setUp(self): def setUp(self):
pass pass
def tearDown(self): def tearDown(self):
pass l.flushdb()
def test_eval(self):
assert l.eval(simple_script, ["key1", "key2"], "first", "second") == ["key1", "key2", "first", "second"]
def test_evalsha(self):
sha1 = l.scriptload(simple_script)
assert len(sha1) == 40
assert l.evalsha(sha1, ["key1", "key2"], "first", "second") == ["key1", "key2", "first", "second"]
def test_scriptload(self):
sha1 = l.scriptload(simple_script)
assert len(sha1) == 40
def test_scriptexists(self):
sha1 = l.scriptload(simple_script)
assert l.scriptexists(sha1) == [1L]
def test_scriptflush(self):
sha1 = l.scriptload(simple_script)
assert l.scriptexists(sha1) == [1L]
assert l.scriptflush() == 'OK'
assert l.scriptexists(sha1) == [0L]
def testEval(self):
assert l.eval("return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", ["key1", "key2"], "first", "second") == ["key1", "key2", "first", "second"]