mirror of https://github.com/ledisdb/ledisdb.git
add tests for py client
This commit is contained in:
parent
210d51258b
commit
6f3f049707
|
@ -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
|
|
@ -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"]
|
||||
|
||||
|
Loading…
Reference in New Issue