Esempio n. 1
0
    def creates_instance_for_memcached_session(self):
        factory = DriverFactory()

        instance = factory.create('memcached', storage_settings={}, storage_category='db_sessions')

        self.assertIsInstance(instance, MemcachedDriver)

        instance.get('client-is-lazy-loaded')

        self.assertIsNotNone(instance.client.get_stats())
Esempio n. 2
0
    def creates_instance_for_memcached_session(self):
        factory = DriverFactory()

        instance = factory.create('memcached', storage_settings={}, storage_category='db_sessions')

        self.assertIsInstance(instance, MemcachedDriver)

        instance.get('client-is-lazy-loaded')

        self.assertIsNotNone(instance.client.get_stats())
Esempio n. 3
0
    def creates_instance_for_redis_session(self):
        factory = DriverFactory()

        instance = factory.create('redis', storage_settings={}, storage_category='db_sessions')

        self.assertIsInstance(instance, RedisDriver)

        instance.get('client-is-lazy-loaded')

        self.assertEqual(instance.client.connection_pool._available_connections[0].db, 0)
Esempio n. 4
0
    def creates_instance_for_redis_session(self):
        factory = DriverFactory()

        instance = factory.create('redis', storage_settings={}, storage_category='db_sessions')

        self.assertIsInstance(instance, RedisDriver)

        instance.get('client-is-lazy-loaded')

        self.assertEqual(instance.client.connection_pool._available_connections[0].db, 0)
Esempio n. 5
0
 def __setup_driver(self):
     """
     通过配置文件和工厂模式创建redis或memcached
     """
     #获得配置信息
     self.__setup_settings()
     #获得数据库配置信息
     storage_settings = self.settings.get('storage', {})
     #实例化工厂类
     factory = DriverFactory()
     #通过传入的参数创建相应的数据库实例
     self.driver = factory.create(self.settings.get('engine'),
                                  storage_settings, self.STORAGE_CATEGORY)
Esempio n. 6
0
    def cannot_create_a_driver_for_not_supported_engine(self):
        factory = DriverFactory()

        factory.create('cassete-tape', storage_settings={}, storage_category='db_sessions')
Esempio n. 7
0
 def __setup_driver(self):
     self.__setup_settings()
     storage_settings = self.settings.get('storage', {})
     factory = DriverFactory()
     self.driver = factory.create(self.settings.get('engine'), storage_settings, self.STORAGE_CATEGORY)
Esempio n. 8
0
    def cannot_create_a_driver_for_not_supported_engine(self):
        factory = DriverFactory()

        factory.create('cassete-tape', storage_settings={}, storage_category='db_sessions')
Esempio n. 9
0
 def __setup_driver(self):
     self.__setup_settings()
     storage_settings = self.settings.get('storage', {})
     factory = DriverFactory()
     self.driver = factory.create(self.settings.get('engine'),
                                  storage_settings, self.STORAGE_CATEGORY)