diff --git a/client/ledis-py/tests/all.sh b/client/ledis-py/tests/all.sh new file mode 100644 index 0000000..163ee04 --- /dev/null +++ b/client/ledis-py/tests/all.sh @@ -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 diff --git a/client/ledis-py/tests/test_cmd_script.py b/client/ledis-py/tests/test_cmd_script.py index 02d7630..4a08cb5 100644 --- a/client/ledis-py/tests/test_cmd_script.py +++ b/client/ledis-py/tests/test_cmd_script.py @@ -12,14 +12,44 @@ from util import expire_at, expire_at_seconds l = ledis.Ledis(port=6380) +simple_script = "return {KEYS[1], KEYS[2], ARGV[1], ARGV[2]}" + + class TestCmdScript(unittest.TestCase): def setUp(self): pass 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"] \ No newline at end of file