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


Python URN.from_jiochat方法代码示例

本文整理汇总了Python中temba.contacts.models.URN.from_jiochat方法的典型用法代码示例。如果您正苦于以下问题:Python URN.from_jiochat方法的具体用法?Python URN.from_jiochat怎么用?Python URN.from_jiochat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在temba.contacts.models.URN的用法示例。


在下文中一共展示了URN.from_jiochat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_claim

# 需要导入模块: from temba.contacts.models import URN [as 别名]
# 或者: from temba.contacts.models.URN import from_jiochat [as 别名]
    def test_claim(self):
        url = reverse("channels.types.jiochat.claim")

        self.login(self.admin)

        # check that claim page URL appears on claim list page
        response = self.client.get(reverse("channels.channel_claim"))
        self.assertContains(response, url)

        # try to claim a channel
        response = self.client.get(url)
        post_data = response.context["form"].initial
        post_data["app_id"] = "foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo"
        post_data["app_secret"] = "barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar"

        response = self.client.post(url, post_data)

        channel = Channel.objects.get(channel_type="JC")

        self.assertEqual(
            channel.config,
            {
                "jiochat_app_id": post_data["app_id"],
                "jiochat_app_secret": post_data["app_secret"],
                "secret": channel.config["secret"],
            },
        )

        config_url = reverse("channels.channel_configuration", args=[channel.uuid])
        self.assertRedirect(response, config_url)

        response = self.client.get(config_url)
        self.assertEqual(200, response.status_code)

        self.assertContains(response, reverse("courier.jc", args=[channel.uuid]))
        self.assertContains(response, channel.config[Channel.CONFIG_SECRET])

        contact = self.create_contact("Jiochat User", urn=URN.from_jiochat("1234"))

        # make sure we our jiochat channel satisfies as a send channel
        response = self.client.get(reverse("contacts.contact_read", args=[contact.uuid]))
        send_channel = response.context["send_channel"]
        self.assertIsNotNone(send_channel)
        self.assertEqual(send_channel.channel_type, "JC")
开发者ID:mxabierto,项目名称:rapidpro,代码行数:46,代码来源:tests.py


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