Ejemplo n.º 1
0
 def testRemove(self):
   """Test the twitter._FileCache.Remove method"""
   cache = twitter._FileCache()
   cache.Set("foo",'Hello World!')
   cache.Remove("foo")
   data = cache.Get("foo")
   self.assertEqual(data, None, 'data is not None')
Ejemplo n.º 2
0
 def testGet(self):
   """Test the twitter._FileCache.Get method"""
   cache = twitter._FileCache()
   cache.Set("foo",'Hello World!')
   data = cache.Get("foo")
   self.assertEqual('Hello World!', data)
   cache.Remove("foo")
Ejemplo n.º 3
0
 def testRemove(self):
     """Test the twitter._FileCache.Remove method"""
     cache = twitter._FileCache()
     cache.Set("foo", 'Hello World!')
     cache.Remove("foo")
     data = cache.Get("foo")
     self.assertEqual(data, None, 'data is not None')
Ejemplo n.º 4
0
 def testGet(self):
     """Test the twitter._FileCache.Get method"""
     cache = twitter._FileCache()
     cache.Set("foo", 'Hello World!')
     data = cache.Get("foo")
     self.assertEqual('Hello World!', data)
     cache.Remove("foo")
Ejemplo n.º 5
0
 def testGetCachedTime(self):
     """Test the twitter._FileCache.GetCachedTime method"""
     now = time.time()
     cache = twitter._FileCache()
     cache.Set("foo", "Hello World!")
     cached_time = cache.GetCachedTime("foo")
     delta = cached_time - now
     self.assert_(delta <= 1, "Cached time differs from clock time by more than 1 second.")
     cache.Remove("foo")
Ejemplo n.º 6
0
 def testGetCachedTime(self):
   """Test the twitter._FileCache.GetCachedTime method"""
   now = time.time()
   cache = twitter._FileCache()
   cache.Set("foo",'Hello World!')
   cached_time = cache.GetCachedTime("foo")
   delta = cached_time - now
   self.assert_(delta <= 1,
                'Cached time differs from clock time by more than 1 second.')
   cache.Remove("foo")
Ejemplo n.º 7
0
    def SetCache(self, cache):
        '''Override the default cache.  Set to None to prevent caching.

        Args:
          cache:
            An instance that supports the same API as the twitter._FileCache
        '''
        if cache == DEFAULT_CACHE:
            self._cache = _FileCache()
        else:
            self._cache = cache
Ejemplo n.º 8
0
    def SetCache(self, cache):
        """Override the default cache.  Set to None to prevent caching.

        Args:
          cache:
            An instance that supports the same API as the twitter._FileCache
        """
        if cache == DEFAULT_CACHE:
            self._cache = _FileCache()
        else:
            self._cache = cache
Ejemplo n.º 9
0
    def __init__(self):
        """One instance of Globals is created during application
        initialization and is available during requests via the
        'app_globals' variable

        """
        here = config['here']
        
        self.twitter_cache = twitter._FileCache(root_directory="%s/data/twitter" % here)
        
        if not 'memcached.server' in config:
            config['memcached.server'] = "127.0.0.1:11211"
        self.cache = memcache.Client([config['memcached.server']])


        # whooo
Ejemplo n.º 10
0
 def testSet(self):
   """Test the twitter._FileCache.Set method"""
   cache = twitter._FileCache()
   cache.Set("foo",'Hello World!')
   cache.Remove("foo")
Ejemplo n.º 11
0
 def testInit(self):
   """Test the twitter._FileCache constructor"""
   cache = twitter._FileCache()
   self.assert_(cache is not None, 'cache is None')
Ejemplo n.º 12
0
 def testSet(self):
     """Test the twitter._FileCache.Set method"""
     cache = twitter._FileCache()
     cache.Set("foo", 'Hello World!')
     cache.Remove("foo")
Ejemplo n.º 13
0
 def testInit(self):
     """Test the twitter._FileCache constructor"""
     cache = twitter._FileCache()
     self.assert_(cache is not None, 'cache is None')