本文整理汇总了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"]))
示例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)