Пример #1
0
    def test_cache_miss_signal(self):
        cb = mock_receiver()
        cache_miss.connect(cb)

        cache.delete('foo')
        cached, primed = cache.get_or_prime('foo', 'bar')

        self.assertTrue(primed)
        self.assertTrue(cb.called)
Пример #2
0
    def test_get_or_prime_primes(self):
        cache.delete('foo')

        # Check that we primed
        cached, primed = cache.get_or_prime('foo', primer='bar')
        self.assertTrue(primed)
        self.assertEqual(cached, 'bar')

        # Subsequent call should not prime
        cached, primed = cache.get_or_prime('foo', primer='baz')
        self.assertFalse(primed)
        self.assertEqual(cached, 'bar')