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


Python PhoneNumber.get_number_pending_verification方法代码示例

本文整理汇总了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)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:56,代码来源:test_phone_numbers.py


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