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


Python ContactService.get_rapid_pro_contact方法代码示例

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


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

示例1: test_should_get_rapid_pro_contact

# 需要导入模块: from eums.services.contact_service import ContactService [as 别名]
# 或者: from eums.services.contact_service.ContactService import get_rapid_pro_contact [as 别名]
    def test_should_get_rapid_pro_contact(self):
        first_name = "Jack"
        last_name = "Bob"
        phone = '+8618192235667'
        outcomes = ["YI105 - PCR 1 KEEP CHILDREN AND MOTHERS"]
        districts = ["Kampala"]
        ips = ["KAMPALA DHO, WAKISO DHO"]
        types = ["END_USER", "IMPLEMENTING_PARTNER"]

        params = {'urn': 'tel:%s' % phone}
        contact = self.generate_eums_contact(districts, first_name, ips, last_name, outcomes, phone, types)
        requests.get = MagicMock(return_value=MagicMock(status_code=200, json=MagicMock(
            return_value=self.generate_add_or_update_rapid_pro_contact_response(contact))))
        response = ContactService.get_rapid_pro_contact(phone)

        requests.get.assert_called_once_with(settings.RAPIDPRO_URLS.get('CONTACTS'), params=params,
                                             headers=HEADER, verify=settings.RAPIDPRO_SSL_VERIFY)

        self.assertEqual(response.status_code, HTTP_200_OK)
        self.assertEqual(len(response.json().get('groups')), 1)
        self.assertEqual(response.json().get('groups')[0], 'EUMS')

        fields = response.json().get("fields")
        self.assertEqual(fields.get('firstname'), first_name)
        self.assertEqual(fields.get('lastname'), last_name)
        self.assertEqual(fields.get('outcomes'), ','.join(outcomes))
        self.assertEqual(fields.get('districts'), ','.join(districts))
        self.assertEqual(fields.get('ips'), ','.join(ips))
        self.assertEqual(fields.get('types'), ','.join(["End-user", "IP"]))
开发者ID:unicefuganda,项目名称:eums,代码行数:31,代码来源:test_contact_service.py

示例2: test_should_not_get_contact_when_rapid_pro_off

# 需要导入模块: from eums.services.contact_service import ContactService [as 别名]
# 或者: from eums.services.contact_service.ContactService import get_rapid_pro_contact [as 别名]
 def test_should_not_get_contact_when_rapid_pro_off(self):
     phone = '+8618192235667'
     requests.get = MagicMock()
     ContactService.get_rapid_pro_contact(phone)
     self.assertFalse(requests.get.called)
开发者ID:unicefuganda,项目名称:eums,代码行数:7,代码来源:test_contact_service.py


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