adding testing for redis

This commit is contained in:
Hossein Shafagh 2019-07-12 11:50:12 -07:00
parent 1b1bdbb261
commit cd1aeb15f1
2 changed files with 14 additions and 1 deletions

View File

@ -23,7 +23,7 @@ class RedisHandler:
def redis(self, db=0): def redis(self, db=0):
# The decode_responses flag here directs the client to convert the responses from Redis into Python strings # 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. # 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 return red

13
lemur/tests/test_redis.py Normal file
View File

@ -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