test_iqiyi_sdk_interpreter.py 995 B

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