def test_url_lists(self): """weblinkback - test URL lists""" add_url_to_list('url1', CFG_WEBLINKBACK_LIST_TYPE['BLACKLIST'], self.user_info) add_url_to_list('url2', CFG_WEBLINKBACK_LIST_TYPE['BLACKLIST'], self.user_info) add_url_to_list('url3', CFG_WEBLINKBACK_LIST_TYPE['WHITELIST'], self.user_info) self.assertEqual(('url1', 'url2'), get_url_list(CFG_WEBLINKBACK_LIST_TYPE['BLACKLIST'])) self.assertEqual(('url3', ), get_url_list(CFG_WEBLINKBACK_LIST_TYPE['WHITELIST'])) remove_url('url2') remove_url('url3') self.assertEqual(('url1', ), get_url_list(CFG_WEBLINKBACK_LIST_TYPE['BLACKLIST'])) self.assertEqual(tuple(), get_url_list(CFG_WEBLINKBACK_LIST_TYPE['WHITELIST']))
def infix_exists_for_url_in_list(url, list_type): """ Check if an infix of a url exists in a list @param url @param list_type, of CFG_WEBLINKBACK_LIST_TYPE @return True, False """ urls = get_url_list(list_type) for current_url in urls: if current_url in url: return True return False