Esempio n. 1
0
    def test_time_too_old(self):
        with mock.patch.object(config, 'CACHE_INTERVAL', 30):
            rdb.set("my-item/updated", seconds_old(30))
            self.assertTrue(backend.too_old("my-item"))

            rdb.set("my-item/updated", seconds_old(29))
            self.assertFalse(backend.too_old("my-item"))
Esempio n. 2
0
    def test_time_too_old(self):
        with mock.patch.object(config, 'CACHE_INTERVAL', 30):
            rdb.set("my-item/updated", seconds_old(30))
            self.assertTrue(backend.too_old("my-item"))

            rdb.set("my-item/updated", seconds_old(29))
            self.assertFalse(backend.too_old("my-item"))
Esempio n. 3
0
    def test_cache_cached_too_old_gets_update(self):
        rdb.set('test_key', STORIES_JSON)

        rdb.set("/test_key/updated", seconds_old(31))

        with mock.patch.object(config, 'CACHE_INTERVAL', 30):
            with mock.patch.object(items.tasks.update, 'delay') as update:
                self.assertEqual(STORIES_JSON,
                                 items._get_cache('test_key', 'test_item'))
                update.assert_called_with('test_key', 'test_item')
Esempio n. 4
0
    def test_cache_cached_too_old_gets_update(self):
        rdb.set('test_key', STORIES_JSON)

        rdb.set("/test_key/updated", seconds_old(31))

        with mock.patch.object(config, 'CACHE_INTERVAL', 30):
            with mock.patch.object(items.tasks.update, 'delay') as update:
                self.assertEqual(STORIES_JSON,
                                 items._get_cache('test_key', 'test_item'))
                update.assert_called_with('test_key', 'test_item')