本文整理匯總了Python中mockredis.MockRedis方法的典型用法代碼示例。如果您正苦於以下問題:Python mockredis.MockRedis方法的具體用法?Python mockredis.MockRedis怎麽用?Python mockredis.MockRedis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mockredis
的用法示例。
在下文中一共展示了mockredis.MockRedis方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_context
# 需要導入模塊: import mockredis [as 別名]
# 或者: from mockredis import MockRedis [as 別名]
def test_context(self):
panoptes_context = PanoptesContext(self.panoptes_test_conf_file)
self.assertIsInstance(panoptes_context, PanoptesContext)
self.assertEqual(panoptes_context.config_object.redis_urls[0].url, u'redis://:password@localhost:6379/0')
self.assertEqual(str(panoptes_context.config_object.redis_urls[0]), u'redis://:**@localhost:6379/0')
self.assertEqual(panoptes_context.config_object.zookeeper_servers, set([u'localhost:2181']))
self.assertEqual(panoptes_context.config_object.kafka_brokers, set([u'localhost:9092']))
self.assertIsInstance(panoptes_context.config_dict, dict)
self.assertIsInstance(panoptes_context.logger, _loggerClass)
self.assertIsInstance(panoptes_context.redis_pool, MockRedis)
with self.assertRaises(AttributeError):
panoptes_context.kafka_client
with self.assertRaises(AttributeError):
panoptes_context.zookeeper_client
del panoptes_context
示例2: __init__
# 需要導入模塊: import mockredis [as 別名]
# 或者: from mockredis import MockRedis [as 別名]
def __init__(self, connection=None, encoding=None, **kwargs):
# Just for API compatibility
self._conn = connection
self._redis = _MockRedis(**kwargs)
self._encoding = encoding
示例3: setUp
# 需要導入模塊: import mockredis [as 別名]
# 或者: from mockredis import MockRedis [as 別名]
def setUp(self):
self.memory = MemoryStorage()
self.redis_object = Redis()
self.redis_storage = RedisStorage(self.redis_object)
示例4: mock_queue_client
# 需要導入模塊: import mockredis [as 別名]
# 或者: from mockredis import MockRedis [as 別名]
def mock_queue_client(monkeypatch):
# Stop mockredis from trying to run Lua imports that aren't really needed.
monkeypatch.setattr('mockredis.script.Script._import_lua_dependencies',
staticmethod(lambda *args, **kwargs: None))
cl = QueueClient(zone='testzone')
cl.redis = mockredis.MockRedis()
return cl