def retrieves_a_pickled_object_from_session(self): driver = RedisDriver(dict(db=0)) foo = dict(foo='bar') self.client.set('session-id', pickle.dumps(foo)) result = driver.get('session-id') self.assertEqual(result, foo)
def inserts_pickable_object_into_session(self): driver = RedisDriver(dict(db=0)) foo = dict(foo='bar') driver.set('session-id', foo) result = self.client.get('session-id') self.assertEqual(pickle.loads(result), foo)
def makes_session_expire_in_one_day_in_the_client(self): driver = RedisDriver(dict(db=0)) foo = dict(foo='bar') test_case = self class StubClient(object): def set(self, session_id, pickled_session): pass def expire(self, session_id, expiration): test_case.assertEqual(expiration, RedisDriver.EXPIRE_SECONDS) driver.client = StubClient() driver.set('session-id', foo)
def _create_redis(self, storage_settings, storage_category): storage_settings = copy(storage_settings) default_storage_identifier = RedisDriver.DEFAULT_STORAGE_IDENTIFIERS[ storage_category] storage_settings['db'] = storage_settings.get( storage_category, default_storage_identifier) for storage_category in self.STORAGE_CATEGORIES: if storage_category in storage_settings.keys(): del storage_settings[storage_category] return RedisDriver(storage_settings)
def starts_with_max_connections(self): driver = RedisDriver(dict(db=0, max_connections=123)) driver.get('some session') self.assertEqual(driver.client.connection_pool.max_connections, 123)
def starts_with_1_day_to_expire_in_database(self): driver = RedisDriver(dict(db=0)) one_day = 24 * 60 * 60 self.assertEqual(driver.EXPIRE_SECONDS, one_day)