def test_without_memory_nor_memcache(self):
     # this should make a request each time
     with patched_supportdoc_fetching():
         cm = SupportDocumentManagerWithCache(memory=False, memcache=False)
         self.assertFalse(cm.memory)
         self.assertFalse(cm.memcache)
         cm.get_support_document('browserid.org')
 def test_without_memory_nor_memcache(self):
     # this should make a request each time
     with patched_supportdoc_fetching():
         cm = SupportDocumentManagerWithCache(memory=False, memcache=False)
         self.assertFalse(cm.memory)
         self.assertFalse(cm.memcache)
         cm.get_support_document('browserid.org')
    def test_memory(self):
        with patched_supportdoc_fetching():
            memory = TTLedDict(1)
            cm = SupportDocumentManagerWithCache(memory=memory)
            self.assertFalse(cm.memcache)
            self.assertEquals(len(cm.memory), 0)

            # getting something should populate the memory
            cm.get_support_document('browserid.org')
            self.assertEquals(len(cm.memory), 1)

            # if we sleep for a while, the value should be invalid
            time.sleep(1)
            self.assertFalse('browserid.org' in memory)
            with self.assertRaises(KeyError):
                memory['browserid.org']
    def test_memory(self):
        with patched_supportdoc_fetching():
            memory = TTLedDict(1)
            cm = SupportDocumentManagerWithCache(memory=memory)
            self.assertFalse(cm.memcache)
            self.assertEquals(len(cm.memory), 0)

            # getting something should populate the memory
            cm.get_support_document('browserid.org')
            self.assertEquals(len(cm.memory), 1)

            # if we sleep for a while, the value should be invalid
            time.sleep(1)
            self.assertFalse('browserid.org' in memory)
            with self.assertRaises(KeyError):
                memory['browserid.org']