]>
Commit | Line | Data |
---|---|---|
cc52de43 | 1 | #!/usr/bin/env python3 |
a4e4d7df YCH |
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 | ||
060ac762 | 11 | from test.helper import FakeYDL, is_download_test |
7a5c1cfe | 12 | from yt_dlp.extractor import IqiyiIE |
a4e4d7df YCH |
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 | ||
060ac762 | 34 | @is_download_test |
a4e4d7df YCH |
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 | ||
582be358 | 47 | |
a4e4d7df YCH |
48 | if __name__ == '__main__': |
49 | unittest.main() |