本文整理匯總了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"))]
)