コード例 #1
0
 def test_persistent_error(self):
     """ Test persistent not cache error """
     registry = getUtility(IRegistry)
     embedly_settings = registry.forInterface(IEmbedlySettings)
     embedly_settings.persistent_cache = True
     get_oembed(self.obj_url, u'1234')
     storage = IAnnotations(self.layer['portal'])
     self.assertEqual(0, len(storage['_embedly_persistent_']))
     get_oembed(self.obj_url)
     self.assertEqual(1, len(storage['_embedly_persistent_']))
コード例 #2
0
 def test_persistent_timeout(self):
     """ Test persistent cache timeout """
     registry = getUtility(IRegistry)
     embedly_settings = registry.forInterface(IEmbedlySettings)
     embedly_settings.persistent_cache = True
     get_oembed(self.obj_url)
     storage = IAnnotations(self.layer['portal'])
     self.assertEqual(1, len(storage['_embedly_persistent_']))
     embedly_settings.cache_timeout = 1
     get_oembed(self.obj_url)
     self.assertEqual(2, len(storage['_embedly_persistent_']))
コード例 #3
0
 def test_cache_timeout(self):
     """ Test cache timeout """
     ramcache = queryUtility(IRAMCache)
     registry = getUtility(IRegistry)
     embedly_settings = registry.forInterface(IEmbedlySettings)
     get_oembed(self.obj_url)
     stats = filter(embedly_filter, ramcache.getStatistics())
     self.assertEqual(1, stats[0]['entries'])
     embedly_settings.cache_timeout = 1
     get_oembed(self.obj_url)
     stats = filter(embedly_filter, ramcache.getStatistics())
     self.assertEqual(2, stats[0]['entries'])
コード例 #4
0
    def test_no_key_url(self):
        """ Test query with initial api_key """
        registry = getUtility(IRegistry)
        embedly_settings = registry.forInterface(IEmbedlySettings)
        self.assertFalse(embedly_settings.api_key)

        res = get_oembed(self.obj_url, embedly_settings.api_key)
        self.assertEqual(res, json_result)
コード例 #5
0
 def test_persistent_entries(self):
     """ Test persistent cache entries """
     registry = getUtility(IRegistry)
     embedly_settings = registry.forInterface(IEmbedlySettings)
     embedly_settings.persistent_cache = True
     res = get_oembed(self.obj_url)
     self.assertEqual(res, json_result)
     storage = IAnnotations(self.layer['portal'])
     self.assertEqual(1, len(storage['_embedly_persistent_']))
コード例 #6
0
    def test_persistent_cache(self):
        """ Test persistent cache """
        registry = getUtility(IRegistry)
        embedly_settings = registry.forInterface(IEmbedlySettings)
        self.assertFalse(embedly_settings.persistent_cache)

        embedly_settings.persistent_cache = True
        res = get_oembed(self.obj_url)
        self.assertEqual(res, json_result)
コード例 #7
0
 def test_cache_stats(self):
     """ Test cache stats """
     ramcache = queryUtility(IRAMCache)
     get_oembed(self.obj_url)
     stats = filter(embedly_filter, ramcache.getStatistics())
     self.assertEqual(0, stats[0]['hits'])
     get_oembed(self.obj_url)
     stats = filter(embedly_filter, ramcache.getStatistics())
     self.assertEqual(1, stats[0]['hits'])
     get_oembed(self.obj_url)
     stats = filter(embedly_filter, ramcache.getStatistics())
     self.assertEqual(2, stats[0]['hits'])
コード例 #8
0
 def test_embedly_params(self):
     """ Test query with additional embedly parameters """
     url = "http://www.youtube.com/watch?v=L1NPLlhFTVk&maxwidth=10&maxheight=10"
     res = get_oembed(url)
     self.assertEqual(res, json_result)
コード例 #9
0
 def test_empty_key(self):
     """ Test query with empty api_key """
     res = get_oembed(self.obj_url, u' ')
     self.assertEqual(res, json_result)
コード例 #10
0
 def test_fake_key(self):
     """ Test query with not valid api_key """
     res = get_oembed(self.obj_url, u'1234')
     self.assertNotEqual(res, json_result)
コード例 #11
0
 def test_normal_key(self):
     """ Test query with embedly api_key """
     res = get_oembed(self.obj_url, u'1234567890abcdef1234567890abcdef')
     self.assertEqual(res, json_result)