adding testing for redis
This commit is contained in:
parent
1b1bdbb261
commit
cd1aeb15f1
|
@ -23,7 +23,7 @@ class RedisHandler:
|
|||
def redis(self, db=0):
|
||||
# The decode_responses flag here directs the client to convert the responses from Redis into Python strings
|
||||
# using the default encoding utf-8. This is client specific.
|
||||
red = redis.StrictRedis(host=self.host, port=self.port, db=self.db, charset="utf-8", decode_responses=True)
|
||||
red = redis.StrictRedis(host=self.host, port=self.port, db=self.db, encoding="utf-8", decode_responses=True)
|
||||
return red
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import fakeredis
|
||||
import time
|
||||
import sys
|
||||
|
||||
|
||||
def test_write_and_read_from_redis():
|
||||
function = f"{__name__}.{sys._getframe().f_code.co_name}"
|
||||
|
||||
red = fakeredis.FakeStrictRedis()
|
||||
key = f"{function}.last_success"
|
||||
value = int(time.time())
|
||||
assert red.set(key, value) is True
|
||||
assert (int(red.get(key)) == value) is True
|
Loading…
Reference in New Issue