Exemple #1
0
 def test20GetString(self):
     """check set and get a string value"""
     r = SRedis()
     # set, get
     r.set(self.TESTKEY, 'somevalue')
     self.assertEquals(r.get(self.TESTKEY), 'somevalue')
     # change, get
     newvalue = "value:%s" % time.time()
     r.set(self.TESTKEY, newvalue)
     self.assertEquals(r.get(self.TESTKEY),newvalue)
Exemple #2
0
 def test30List(self):
     """check list workings"""
     r = SRedis()
     K = self.TESTKEY
     # push
     r.lpush(K, "v10")
     r.lpush(K, "v20")
     r.lpush(K, "v30")
     r.lpush(K, "v40")
     self.assertEquals(r.llen(K), 4)
     self.assertEquals(r.lpop(K), "v40")
     self.assertEquals(r.llen(K), 3)
     # trim
     r.ltrim(K, 0, 1) # would be [0:2] in python.
     self.assertEquals(r.llen(K), 2) # 'v10' was dropped
     # pop
     self.assertEquals(r.lpop(K), "v30")
     self.assertEquals(r.lpop(K), "v20")
     self.assertEquals(r.lpop(K), None)
Exemple #3
0
 def test01Connect(self):
     """check basic connection to redis"""
     r = SRedis()
     self.assertEquals(r.get(self.TESTKEY), None)
Exemple #4
0
 def test10SetString(self):
     """check set a string value"""
     r = SRedis()
     r.set(self.TESTKEY, 'somevalue')
Exemple #5
0
 def tearDown(self):
     r = SRedis()
     r.delete(self.TESTKEY)