Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_can_pass_through_extra_args(self):
db = fakeredis.FakeStrictRedis.from_url(
'redis://username:password@localhost:6379/0',
decode_responses=True)
db.set('foo', 'bar')
self.assertEqual(db.get('foo'), 'bar')
def test_from_url(self):
db = fakeredis.FakeStrictRedis.from_url(
'redis://username:password@localhost:6379/0')
db.set('foo', 'bar')
self.assertEqual(db.get('foo'), b'bar')
def test_from_url_with_db_arg(self):
db = fakeredis.FakeStrictRedis.from_url(
'redis://username:password@localhost:6379/0')
db1 = fakeredis.FakeStrictRedis.from_url(
'redis://username:password@localhost:6379/1')
db2 = fakeredis.FakeStrictRedis.from_url(
'redis://username:password@localhost:6379/',
db=2)
db.set('foo', 'foo0')
db1.set('foo', 'foo1')
db2.set('foo', 'foo2')
self.assertEqual(db.get('foo'), b'foo0')
self.assertEqual(db1.get('foo'), b'foo1')
self.assertEqual(db2.get('foo'), b'foo2')
def test_from_url_with_db_arg(self):
db = fakeredis.FakeStrictRedis.from_url(
'redis://username:password@localhost:6379/0')
db1 = fakeredis.FakeStrictRedis.from_url(
'redis://username:password@localhost:6379/1')
db2 = fakeredis.FakeStrictRedis.from_url(
'redis://username:password@localhost:6379/',
db=2)
db.set('foo', 'foo0')
db1.set('foo', 'foo1')
db2.set('foo', 'foo2')
self.assertEqual(db.get('foo'), b'foo0')
self.assertEqual(db1.get('foo'), b'foo1')
self.assertEqual(db2.get('foo'), b'foo2')
def test_from_url_with_db_arg(self):
db = fakeredis.FakeStrictRedis.from_url(
'redis://username:password@localhost:6379/0')
db1 = fakeredis.FakeStrictRedis.from_url(
'redis://username:password@localhost:6379/1')
db2 = fakeredis.FakeStrictRedis.from_url(
'redis://username:password@localhost:6379/',
db=2)
db.set('foo', 'foo0')
db1.set('foo', 'foo1')
db2.set('foo', 'foo2')
self.assertEqual(db.get('foo'), b'foo0')
self.assertEqual(db1.get('foo'), b'foo1')
self.assertEqual(db2.get('foo'), b'foo2')
def test_from_url_db_value_error(self):
# In ValueError, should default to 0
db = fakeredis.FakeStrictRedis.from_url(
'redis://username:password@localhost:6379/a')
self.assertEqual(db._db_num, 0)