Created
October 8, 2013 17:57
-
-
Save gotche/6888746 to your computer and use it in GitHub Desktop.
proof of concept for mockredis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RedisConcept(): | |
def __init__(self): | |
self.host = "localhost" | |
self.port = "6379" | |
self.db = "1" | |
self.r = redis.Redis(host=self.host, port=self.port, db=self.db) | |
def get_key(self, key): | |
return self.r.get(key) | |
def set_key(self, key, value): | |
self.r.set(key, value) | |
@patch("redis.Redis", MockRedis) | |
class RedisTestCase(TestCase): | |
def test_redisworking(self): | |
r = RedisConcept() | |
r.set_key("a", "3") | |
self.assertEqual("3", r.get_key("a")) | |
r = RedisConcept() | |
self.assertEqual("3", r.get_key("a")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment