예제 #1
0
 def test_indices(self):
     cache = MongoCache(**self.OPTIONS)
     for op in ['op1', 'op2']:
         for key in ['key1', 'key2']:
             try:
                 cache.lock(op, key)
                 cache.fill(op, key, 'content')
             finally:
                 cache.release(op, key)
예제 #2
0
 def test_lock(self):
     cache = MongoCache(**self.OPTIONS)
     cache.lock('foo', 'bar')
     try:
         with self.assertRaises(ResourceLocked) as exc:
             cache.lock('foo', 'bar')
         self.assertEqual(exc.exception.operation, 'foo')
         self.assertEqual(exc.exception.uri, 'bar')
     finally:
         cache.release('foo', 'bar')
예제 #3
0
    def test_fill_redirects(self):
        cache = MongoCache(**self.OPTIONS)
        self._insert_foo_bar_doc(cache)
        self.assertEqual(cache.get('foo', 'lol')[1], 'content')

        # Now let's add a redirect
        try:
            cache.lock('foo', 'bar')
            cache.fill('foo', 'bar', None, ['bonjour'])
        finally:
            cache.release('foo', 'bar')
        self.assertEqual(cache.get('foo', 'bonjour')[1], 'content')
        self.assertEqual(cache.get('foo', 'lol')[1], 'content')