def test_load_cookies(self): dirname, filename = os.path.split(os.path.abspath(__file__)) cookies = dirname + '/example_cookies.txt' session_cookies = YouTubeTranscriptApi._load_cookies( cookies, 'GJLlxj_dtq8') self.assertEqual({'TEST_FIELD': 'TEST_VALUE'}, requests.utils.dict_from_cookiejar(session_cookies))
def test_load_cookies__no_valid_cookies(self): dirname, filename = os.path.split(os.path.abspath(__file__)) expired_cookies = dirname + '/expired_example_cookies.txt' with self.assertRaises(CookiesInvalid): YouTubeTranscriptApi._load_cookies(expired_cookies, 'GJLlxj_dtq8')
def test_load_cookies__bad_file_path(self): bad_cookies = 'nonexistent_cookies.txt' with self.assertRaises(CookiePathInvalid): YouTubeTranscriptApi._load_cookies(bad_cookies, 'GJLlxj_dtq8')