本文整理汇总了Python中streamlink.plugin.Plugin.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Plugin.bind方法的具体用法?Python Plugin.bind怎么用?Python Plugin.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类streamlink.plugin.Plugin
的用法示例。
在下文中一共展示了Plugin.bind方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cookie_store_load
# 需要导入模块: from streamlink.plugin import Plugin [as 别名]
# 或者: from streamlink.plugin.Plugin import bind [as 别名]
def test_cookie_store_load(self):
session = Mock()
session.http.cookies = requests.cookies.RequestsCookieJar()
Plugin.bind(session, 'tests.test_plugin')
Plugin.cache = Mock()
Plugin.cache.get_all.return_value = {
"__cookie:test-name:test.se:80:/": self._create_cookie_dict("test-name", "test-value", None)
}
plugin = Plugin("http://test.se")
self.assertSequenceEqual(
list(map(self._cookie_to_dict, session.http.cookies)),
[self._cookie_to_dict(requests.cookies.create_cookie("test-name", "test-value", domain="test.se"))]
)
示例2: test_cookie_store_save
# 需要导入模块: from streamlink.plugin import Plugin [as 别名]
# 或者: from streamlink.plugin.Plugin import bind [as 别名]
def test_cookie_store_save(self):
session = Mock()
session.http.cookies = [
requests.cookies.create_cookie("test-name", "test-value", domain="test.se")
]
Plugin.bind(session, 'tests.test_plugin')
Plugin.cache = Mock()
Plugin.cache.get_all.return_value = {}
plugin = Plugin("http://test.se")
plugin.save_cookies(default_expires=3600)
Plugin.cache.set.assert_called_with("__cookie:test-name:test.se:80:/",
self._create_cookie_dict("test-name", "test-value", None),
3600)
示例3: test_cookie_store_save_expires
# 需要导入模块: from streamlink.plugin import Plugin [as 别名]
# 或者: from streamlink.plugin.Plugin import bind [as 别名]
def test_cookie_store_save_expires(self):
with freezegun.freeze_time(datetime.datetime(2018, 1, 1)):
session = Mock()
session.http.cookies = [
requests.cookies.create_cookie("test-name", "test-value", domain="test.se", expires=time.time() + 3600,
rest={'HttpOnly': None})
]
Plugin.bind(session, 'tests.test_plugin')
Plugin.cache = Mock()
Plugin.cache.get_all.return_value = {}
plugin = Plugin("http://test.se")
plugin.save_cookies(default_expires=60)
Plugin.cache.set.assert_called_with("__cookie:test-name:test.se:80:/",
self._create_cookie_dict("test-name", "test-value", 1514768400),
3600)
示例4: test_cookie_store_clear
# 需要导入模块: from streamlink.plugin import Plugin [as 别名]
# 或者: from streamlink.plugin.Plugin import bind [as 别名]
def test_cookie_store_clear(self):
session = Mock()
session.http.cookies = requests.cookies.RequestsCookieJar()
Plugin.bind(session, 'tests.test_plugin')
Plugin.cache = Mock()
Plugin.cache.get_all.return_value = {
"__cookie:test-name:test.se:80:/": self._create_cookie_dict("test-name", "test-value", None),
"__cookie:test-name2:test.se:80:/": self._create_cookie_dict("test-name2", "test-value2", None)
}
plugin = Plugin("http://test.se")
# non-empty cookiejar
self.assertTrue(len(session.http.cookies.get_dict()) > 0)
plugin.clear_cookies()
self.assertSequenceEqual(
Plugin.cache.set.mock_calls,
[call("__cookie:test-name:test.se:80:/", None, 0),
call("__cookie:test-name2:test.se:80:/", None, 0)])
self.assertSequenceEqual(session.http.cookies, [])
示例5: test_cookie_store_clear_filter
# 需要导入模块: from streamlink.plugin import Plugin [as 别名]
# 或者: from streamlink.plugin.Plugin import bind [as 别名]
def test_cookie_store_clear_filter(self):
session = Mock()
session.http.cookies = requests.cookies.RequestsCookieJar()
Plugin.bind(session, 'tests.test_plugin')
Plugin.cache = Mock()
Plugin.cache.get_all.return_value = {
"__cookie:test-name:test.se:80:/": self._create_cookie_dict("test-name", "test-value", None),
"__cookie:test-name2:test.se:80:/": self._create_cookie_dict("test-name2", "test-value2", None)
}
plugin = Plugin("http://test.se")
# non-empty cookiejar
self.assertTrue(len(session.http.cookies.get_dict()) > 0)
plugin.clear_cookies(lambda c: c.name.endswith("2"))
self.assertSequenceEqual(
Plugin.cache.set.mock_calls,
[call("__cookie:test-name2:test.se:80:/", None, 0)])
self.assertSequenceEqual(
list(map(self._cookie_to_dict, session.http.cookies)),
[self._cookie_to_dict(requests.cookies.create_cookie("test-name", "test-value", domain="test.se"))]
)