当前位置: 首页>>代码示例>>Python>>正文


Python Channel.refresh_hipchat_access_token方法代码示例

本文整理汇总了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)
开发者ID:cogzidel,项目名称:healthchecks,代码行数:30,代码来源:views.py

示例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)
开发者ID:cogzidel,项目名称:healthchecks,代码行数:15,代码来源:test_channel_model.py


注:本文中的hc.api.models.Channel.refresh_hipchat_access_token方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。