]> Raphaƫl G. Git Repositories - youtubedl/blob - test/test_iqiyi_sdk_interpreter.py
New upstream version 2018.03.14
[youtubedl] / test / test_iqiyi_sdk_interpreter.py
1 #!/usr/bin/env python
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
12 from youtube_dl.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 class TestIqiyiSDKInterpreter(unittest.TestCase):
35 def test_iqiyi_sdk_interpreter(self):
36 '''
37 Test the functionality of IqiyiSDKInterpreter by trying to log in
38
39 If `sign` is incorrect, /validate call throws an HTTP 556 error
40 '''
41 logger = WarningLogger()
42 ie = IqiyiIEWithCredentials(FakeYDL({'logger': logger}))
43 ie._login()
44 self.assertTrue('unable to log in:' in logger.messages[0])
45
46
47 if __name__ == '__main__':
48 unittest.main()