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