logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

test_iqiyi_sdk_interpreter.py (1104B)


  1. #!/usr/bin/env python
  2. from __future__ import unicode_literals
  3. # Allow direct execution
  4. import os
  5. import sys
  6. import unittest
  7. sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  8. from test.helper import FakeYDL
  9. from youtube_dl.extractor import IqiyiIE
  10. class IqiyiIEWithCredentials(IqiyiIE):
  11. def _get_login_info(self):
  12. return 'foo', 'bar'
  13. class WarningLogger(object):
  14. def __init__(self):
  15. self.messages = []
  16. def warning(self, msg):
  17. self.messages.append(msg)
  18. def debug(self, msg):
  19. pass
  20. def error(self, msg):
  21. pass
  22. class TestIqiyiSDKInterpreter(unittest.TestCase):
  23. def test_iqiyi_sdk_interpreter(self):
  24. '''
  25. Test the functionality of IqiyiSDKInterpreter by trying to log in
  26. If `sign` is incorrect, /validate call throws an HTTP 556 error
  27. '''
  28. logger = WarningLogger()
  29. ie = IqiyiIEWithCredentials(FakeYDL({'logger': logger}))
  30. ie._login()
  31. self.assertTrue('unable to log in:' in logger.messages[0])
  32. if __name__ == '__main__':
  33. unittest.main()