2021-01-18 22:39:18 +01:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
# Allow direct execution
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import unittest
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
|
|
|
|
from haruhi_dl.compat import compat_str
|
2021-01-18 22:57:17 +01:00
|
|
|
from haruhi_dl.utils import ExtractorError
|
2021-01-18 22:39:18 +01:00
|
|
|
|
|
|
|
from haruhi_dl.playwright import PlaywrightHelper
|
|
|
|
|
|
|
|
|
|
|
|
class TestPlaywright(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_import_nonfatal(self):
|
|
|
|
PlaywrightHelper._import_pw(fatal=False)
|
|
|
|
|
|
|
|
def test_import_fatal(self):
|
|
|
|
helper = PlaywrightHelper
|
|
|
|
try:
|
|
|
|
helper._import_pw(fatal=True)
|
|
|
|
self.assertIsNotNone(helper._pw)
|
|
|
|
self.assertIsInstance(helper._pw_version, compat_str)
|
2021-01-18 22:57:17 +01:00
|
|
|
except ExtractorError:
|
2021-01-18 22:39:18 +01:00
|
|
|
self.assertIsNone(helper._pw)
|
|
|
|
self.assertIsNone(helper._pw_version)
|
|
|
|
|
|
|
|
def test_checking_version(self):
|
2021-01-18 22:57:17 +01:00
|
|
|
helper = PlaywrightHelper
|
|
|
|
version = helper._version()
|
|
|
|
if helper._pw:
|
|
|
|
self.assertIsInstance(version, compat_str)
|
|
|
|
else:
|
|
|
|
self.assertIsNone(version)
|
2021-01-18 22:39:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|