]> jfr.im git - yt-dlp.git/blob - test/test_iqiyi_sdk_interpreter.py
[youtube] Fix throttling by decrypting n-sig (#1437)
[yt-dlp.git] / test / test_iqiyi_sdk_interpreter.py
1 #!/usr/bin/env python3
2
3 from __future__ import unicode_literals
4
5 # Allow direct execution
6 import os
7 import sys
8 import unittest
9 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10
11 from test.helper import FakeYDL, is_download_test
12 from yt_dlp.extractor import IqiyiIE
13
14
15 class IqiyiIEWithCredentials(IqiyiIE):
16 def _get_login_info(self):
17 return 'foo', 'bar'
18
19
20 class WarningLogger(object):
21 def __init__(self):
22 self.messages = []
23
24 def warning(self, msg):
25 self.messages.append(msg)
26
27 def debug(self, msg):
28 pass
29
30 def error(self, msg):
31 pass
32
33
34 @is_download_test
35 class TestIqiyiSDKInterpreter(unittest.TestCase):
36 def test_iqiyi_sdk_interpreter(self):
37 '''
38 Test the functionality of IqiyiSDKInterpreter by trying to log in
39
40 If `sign` is incorrect, /validate call throws an HTTP 556 error
41 '''
42 logger = WarningLogger()
43 ie = IqiyiIEWithCredentials(FakeYDL({'logger': logger}))
44 ie._login()
45 self.assertTrue('unable to log in:' in logger.messages[0])
46
47
48 if __name__ == '__main__':
49 unittest.main()