本文整理汇总了Python中streamlink.plugin.Plugin.save_cookies方法的典型用法代码示例。如果您正苦于以下问题:Python Plugin.save_cookies方法的具体用法?Python Plugin.save_cookies怎么用?Python Plugin.save_cookies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类streamlink.plugin.Plugin
的用法示例。
在下文中一共展示了Plugin.save_cookies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cookie_store_save
# 需要导入模块: from streamlink.plugin import Plugin [as 别名]
# 或者: from streamlink.plugin.Plugin import save_cookies [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)
示例2: test_cookie_store_save_expires
# 需要导入模块: from streamlink.plugin import Plugin [as 别名]
# 或者: from streamlink.plugin.Plugin import save_cookies [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)