def test_helpers_get_cache(self): cache = SimpleCache() key = 'test' original_value = "Item Value" value = "Item Value" def get_item(): return value self.assertEqual(helpers.get_cache(cache, key, get_item), value) value = "Item Value Changed" # item should still be in cache so the item value is not changed self.assertNotEqual(get_item(), original_value) self.assertEqual(helpers.get_cache(cache, key, get_item), original_value)
def get_request(self): """get the current request being verified""" def get_request(): return db.get_identity(long(self.id.data)) verify_request = get_cache(cache, Identity.get_key(self.id.data), get_request, 15 * 60) if not verify_request: verify_request = db.get_identity(self.id.data) return self.update_verify_request(verify_request)