def _get_cache_policy(filename): # never invalidate config files if filename.startswith('contenu%2Fmedias'): return None uri = _filename_to_url(filename) # short cache for lists if not uri.endswith('.htm') or utils.get_relative_url(uri).count('/') == 0: return SHORT_EXPIRY # anything else follows the default expiry time return DEFAULT_EXPIRY
def test_get_relative_url_homepage_slash(self): expected = 'http://www.jeuxvideo.com/' actual = get_relative_url('http://www.jeuxvideo.com/') self.assertEqual(actual, expected)
def _url_to_filename(url): url = utils.get_relative_url(url) return urllib.parse.quote(url, safe='')
def test_get_relative_url_relative(self): expected = 'videos/chroniques/434958/speed-game-live-any-majora-s-mask-fini-en-moins-de-1h35.htm' actual = get_relative_url('videos/chroniques/434958/speed-game-live-any-majora-s-mask-fini-en-moins-de-1h35.htm') self.assertEqual(actual, expected)