Beispiel #1
0
    def retrieves_a_pickled_object_from_session(self):
        driver = MemcachedDriver({'servers': ('localhost:11211', )})

        foo = dict(foo='bar')

        self.client.set('session-id', pickle.dumps(foo))

        result = driver.get('session-id')

        self.assertEqual(result, foo)
Beispiel #2
0
    def inserts_pickable_object_into_session(self):
        driver = MemcachedDriver({'servers': ('localhost:11211', )})

        foo = dict(foo='bar')

        driver.set('session-id', foo)

        result = self.client.get('session-id')

        self.assertEqual(pickle.loads(result), foo)
Beispiel #3
0
    def retrieves_a_pickled_object_from_session(self):
        driver = MemcachedDriver({
            'servers': ('localhost:11211',)
        })

        foo = dict(foo='bar')

        self.client.set('session-id', pickle.dumps(foo))

        result = driver.get('session-id')

        self.assertEqual(result, foo)
Beispiel #4
0
    def inserts_pickable_object_into_session(self):
        driver = MemcachedDriver({
            'servers': ('localhost:11211',)
        })

        foo = dict(foo='bar')

        driver.set('session-id', foo)

        result = self.client.get('session-id')

        self.assertEqual(pickle.loads(result), foo)
Beispiel #5
0
    def makes_session_expire_in_one_day_in_the_client(self):
        driver = MemcachedDriver({'servers': ('localhost:11211', )})

        foo = dict(foo='bar')

        test_case = self

        class StubClient(object):
            def set(self, session_id, pickled_session, expiration):
                test_case.assertEqual(expiration,
                                      MemcachedDriver.EXPIRE_SECONDS)

        driver.client = StubClient()

        driver.set('session-id', foo)
Beispiel #6
0
    def makes_session_expire_in_one_day_in_the_client(self):
        driver = MemcachedDriver({
            'servers': ('localhost:11211',)
        })

        foo = dict(foo='bar')

        test_case = self

        class StubClient(object):
            def set(self, session_id, pickled_session, expiration):
                test_case.assertEqual(expiration, MemcachedDriver.EXPIRE_SECONDS)

        driver.client = StubClient()

        driver.set('session-id', foo)
Beispiel #7
0
    def starts_with_1_day_to_expire_in_database(self):
        driver = MemcachedDriver({
            'servers': ('localhost:11211',)
        })

        one_day = 24 * 60 * 60

        self.assertEqual(driver.EXPIRE_SECONDS, one_day)
Beispiel #8
0
    def fails_to_load_if_storage_settings_contain_wrong_host(self):
        driver = MemcachedDriver({
            'servers': ('255.255.255.255:99999',)
        })

        driver.set('session-id', 'foo')
Beispiel #9
0
    def fails_to_load_if_storage_settings_contain_wrong_host(self):
        driver = MemcachedDriver({
            'servers': ('255.255.255.255:99999',)
        })

        driver.set('session-id', 'foo')
Beispiel #10
0
 def _create_memcached(self, storage_settings, storage_category):
     return MemcachedDriver(storage_settings)