]> jfr.im git - yt-dlp.git/blame - test/test_iqiyi_sdk_interpreter.py
[test] Use `pytest` instead of `nosetests` (#482)
[yt-dlp.git] / test / test_iqiyi_sdk_interpreter.py
CommitLineData
cc52de43 1#!/usr/bin/env python3
a4e4d7df
YCH
2
3from __future__ import unicode_literals
4
5# Allow direct execution
6import os
7import sys
8import unittest
9sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10
060ac762 11from test.helper import FakeYDL, is_download_test
7a5c1cfe 12from yt_dlp.extractor import IqiyiIE
a4e4d7df
YCH
13
14
15class IqiyiIEWithCredentials(IqiyiIE):
16 def _get_login_info(self):
17 return 'foo', 'bar'
18
19
20class 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
35class 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
48if __name__ == '__main__':
49 unittest.main()