本文整理汇总了Python中corehq.apps.sms.models.PhoneNumber.get_number_pending_verification方法的典型用法代码示例。如果您正苦于以下问题:Python PhoneNumber.get_number_pending_verification方法的具体用法?Python PhoneNumber.get_number_pending_verification怎么用?Python PhoneNumber.get_number_pending_verification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.sms.models.PhoneNumber
的用法示例。
在下文中一共展示了PhoneNumber.get_number_pending_verification方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_number_pending_verification
# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import get_number_pending_verification [as 别名]
def test_get_number_pending_verification(self):
number1 = PhoneNumber.objects.create(
domain=self.domain,
owner_doc_type='X',
owner_id='X',
phone_number='999123',
verified=False,
pending_verification=True,
is_two_way=False
)
PhoneNumber.objects.create(
domain=self.domain,
owner_doc_type='X',
owner_id='X',
phone_number='999123',
verified=False,
pending_verification=False,
is_two_way=False
)
self.assertIsNone(PhoneNumber.get_two_way_number('999123'))
self.assertIsNone(PhoneNumber.get_two_way_number('999124'))
self.assertEqual(PhoneNumber.get_number_pending_verification('999123'), number1)
self.assertEqual(PhoneNumber.get_number_pending_verification('+999 123'), number1)
self.assertIsNone(PhoneNumber.get_number_pending_verification('999124'))
self.assertEqual(PhoneNumber.count_by_domain(self.domain), 2)
# test cache clear on save
number1.phone_number = '999124'
number1.save()
self.assertIsNone(PhoneNumber.get_two_way_number('999123'))
self.assertIsNone(PhoneNumber.get_two_way_number('999124'))
self.assertIsNone(PhoneNumber.get_number_pending_verification('999123'))
self.assertEqual(PhoneNumber.get_number_pending_verification('999124'), number1)
self.assertEqual(PhoneNumber.count_by_domain(self.domain), 2)
# test promotion to two-way
number1.set_two_way()
number1.set_verified()
number1.save()
self.assertIsNone(PhoneNumber.get_two_way_number('999123'))
self.assertEqual(PhoneNumber.get_two_way_number('999124'), number1)
self.assertIsNone(PhoneNumber.get_number_pending_verification('999123'))
self.assertIsNone(PhoneNumber.get_number_pending_verification('999124'))
self.assertEqual(PhoneNumber.count_by_domain(self.domain), 2)
# test cache clear on delete
number1.delete()
self.assertIsNone(PhoneNumber.get_two_way_number('999123'))
self.assertIsNone(PhoneNumber.get_two_way_number('999124'))
self.assertIsNone(PhoneNumber.get_number_pending_verification('999123'))
self.assertIsNone(PhoneNumber.get_number_pending_verification('999124'))
self.assertEqual(PhoneNumber.count_by_domain(self.domain), 1)