本文整理汇总了Python中hc.api.models.Channel.refresh_hipchat_access_token方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.refresh_hipchat_access_token方法的具体用法?Python Channel.refresh_hipchat_access_token怎么用?Python Channel.refresh_hipchat_access_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hc.api.models.Channel
的用法示例。
在下文中一共展示了Channel.refresh_hipchat_access_token方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_hipchat
# 需要导入模块: from hc.api.models import Channel [as 别名]
# 或者: from hc.api.models.Channel import refresh_hipchat_access_token [as 别名]
def add_hipchat(request):
if "installable_url" in request.GET:
url = request.GET["installable_url"]
assert url.startswith("https://api.hipchat.com")
response = requests.get(url)
if "oauthId" not in response.json():
messages.warning(request, "Something went wrong!")
return redirect("hc-channels")
channel = Channel(kind="hipchat")
channel.user = request.team.user
channel.value = response.text
channel.save()
channel.refresh_hipchat_access_token()
channel.assign_all_checks()
messages.success(request, "The HipChat integration has been added!")
return redirect("hc-channels")
install_url = "https://www.hipchat.com/addons/install?" + urlencode({
"url": settings.SITE_ROOT + reverse("hc-hipchat-capabilities")
})
ctx = {
"page": "channels",
"install_url": install_url
}
return render(request, "integrations/add_hipchat.html", ctx)
示例2: test_it_refreshes_hipchat_access_token
# 需要导入模块: from hc.api.models import Channel [as 别名]
# 或者: from hc.api.models.Channel import refresh_hipchat_access_token [as 别名]
def test_it_refreshes_hipchat_access_token(self, mock_post):
mock_post.return_value.json.return_value = {"expires_in": 100}
channel = Channel(kind="hipchat", user=self.alice, value=json.dumps({
"oauthId": "foo",
"oauthSecret": "bar"
}))
channel.refresh_hipchat_access_token()
# It should request a token using a correct tokenUrl
mock_post.assert_called()
self.assertTrue("expires_at" in channel.value)