コード例 #1
0
    def test_get_exists(self):
        """Test that the value is returned if a key has been saved."""
        CacheService.set_value_for_key('fake_key', 'fake_value')

        self.assertEquals(
            CacheService.fetch_value_for_key('fake_key'),
            'fake_value',
        )
コード例 #2
0
ファイル: test_cache_service.py プロジェクト: minglecm/ocelot
    def test_get_exists(self):
        """Test that the value is returned if a key has been saved."""
        CacheService.set_value_for_key('fake_key', 'fake_value')

        self.assertEquals(
            CacheService.fetch_value_for_key('fake_key'),
            'fake_value',
        )
コード例 #3
0
    def _mark_hash_seen(self, data_hash):
        """Adds the data hash to the cache.

        :param str data_hash: hash to store
        """
        CacheService.set_value_for_key(
            self._get_cache_key(data_hash),
            data_hash,
        )
コード例 #4
0
    def _mark_hash_seen(self, data_hash):
        """Adds the data hash to the cache.

        :param str data_hash: hash to store
        """
        CacheService.set_value_for_key(
            self._get_cache_key(data_hash),
            data_hash,
        )
コード例 #5
0
ファイル: test_cache_service.py プロジェクト: minglecm/ocelot
    def test_ttl(self):
        """Test that a key can expire."""
        with freeze_time('2014-01-01T00:00:00'):
            CacheService.set_value_for_key('fake_key', 'fake_value', ttl=5)

            self.assertEquals(
                CacheService.fetch_value_for_key('fake_key'),
                'fake_value',
            )

        with freeze_time('2014-01-01T00:00:06'):
            self.assertIsNone(CacheService.fetch_value_for_key('fake_key'), )
コード例 #6
0
    def test_ttl(self):
        """Test that a key can expire."""
        with freeze_time('2014-01-01T00:00:00'):
            CacheService.set_value_for_key('fake_key', 'fake_value', ttl=5)

            self.assertEquals(
                CacheService.fetch_value_for_key('fake_key'),
                'fake_value',
            )

        with freeze_time('2014-01-01T00:00:06'):
            self.assertIsNone(
                CacheService.fetch_value_for_key('fake_key'),
            )