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


Python PhoneNumber.by_owner_id方法代码示例

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


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

示例1: test_by_owner_id

# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import by_owner_id [as 别名]
    def test_by_owner_id(self):
        number = PhoneNumber.objects.create(
            domain=self.domain,
            owner_doc_type='X',
            owner_id='owner1',
            phone_number='999123',
            verified=True,
            pending_verification=False,
            is_two_way=True
        )

        [lookup] = PhoneNumber.by_owner_id('owner1')
        self.assertEqual(lookup, number)

        # test cache clear
        number.owner_id = 'owner2'
        number.save()
        self.assertEqual(PhoneNumber.by_owner_id('owner1'), [])
        [lookup] = PhoneNumber.by_owner_id('owner2')
        self.assertEqual(lookup, number)

        number.verified = False
        number.is_two_way = False
        number.save()
        [lookup] = PhoneNumber.by_owner_id('owner2')
        self.assertFalse(lookup.verified)
        self.assertFalse(lookup.is_two_way)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:29,代码来源:test_phone_numbers.py

示例2: assertMatch

# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import by_owner_id [as 别名]
    def assertMatch(self, match, phone_search, suffix_search, owner_id_search):
        lookedup = PhoneNumber.get_two_way_number(phone_search)
        self.assertPhoneNumbersEqual(match, lookedup)

        lookedup = PhoneNumber.get_two_way_number_by_suffix(suffix_search)
        self.assertPhoneNumbersEqual(match, lookedup)

        [lookedup] = PhoneNumber.by_owner_id(owner_id_search)
        self.assertPhoneNumbersEqual(match, lookedup)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:11,代码来源:test_phone_numbers.py

示例3: test_by_owner_id

# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import by_owner_id [as 别名]
    def test_by_owner_id(self):
        number = PhoneNumber.objects.create(
            domain=self.domain,
            owner_doc_type='X',
            owner_id='owner1',
            phone_number='999123',
            verified=True
        )

        [lookup] = PhoneNumber.by_owner_id('owner1')
        self.assertEqual(lookup, number)

        # test cache clear
        number.owner_id = 'owner2'
        number.save()
        self.assertEqual(PhoneNumber.by_owner_id('owner1').count(), 0)
        [lookup] = PhoneNumber.by_owner_id('owner2')
        self.assertEqual(lookup, number)

        number.verified = False
        number.save()
        [lookup] = PhoneNumber.by_owner_id('owner2')
        self.assertFalse(lookup.verified)
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:25,代码来源:test_phone_numbers.py

示例4: test_delete_phone_numbers_for_owners

# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import by_owner_id [as 别名]
    def test_delete_phone_numbers_for_owners(self):
        with self.create_case_contact('9990001') as case1, \
                self.create_case_contact('9990002') as case2, \
                self.create_case_contact('9990003') as case3:

            self.assertEqual(PhoneNumber.by_owner_id(case1.case_id).count(), 1)
            self.assertEqual(PhoneNumber.by_owner_id(case2.case_id).count(), 1)
            self.assertEqual(PhoneNumber.by_owner_id(case3.case_id).count(), 1)

            delete_phone_numbers_for_owners([case2.case_id, case3.case_id])
            self.assertEqual(PhoneNumber.by_owner_id(case1.case_id).count(), 1)
            self.assertEqual(PhoneNumber.by_owner_id(case2.case_id).count(), 0)
            self.assertEqual(PhoneNumber.by_owner_id(case3.case_id).count(), 0)
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:15,代码来源:test_phone_numbers.py

示例5: get_verified_numbers

# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import by_owner_id [as 别名]
 def get_verified_numbers(self, include_pending=False):
     from corehq.apps.sms.models import PhoneNumber
     v = PhoneNumber.by_owner_id(self.get_id)
     v = filter(lambda c: c.verified or include_pending, v)
     return dict((c.phone_number, c) for c in v)
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:7,代码来源:mixin.py

示例6: get_two_way_numbers

# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import by_owner_id [as 别名]
 def get_two_way_numbers(self):
     from corehq.apps.sms.models import PhoneNumber
     two_way_entries = [p for p in PhoneNumber.by_owner_id(self.get_id) if p.is_two_way]
     return {
         p.phone_number: p for p in two_way_entries
     }
开发者ID:dimagi,项目名称:commcare-hq,代码行数:8,代码来源:mixin.py

示例7: get_phone_entries

# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import by_owner_id [as 别名]
 def get_phone_entries(self):
     from corehq.apps.sms.models import PhoneNumber
     return {
         p.phone_number: p
         for p in PhoneNumber.by_owner_id(self.get_id)
     }
开发者ID:dimagi,项目名称:commcare-hq,代码行数:8,代码来源:mixin.py

示例8: assertNoMatch

# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import by_owner_id [as 别名]
 def assertNoMatch(self, phone_search, suffix_search, owner_id_search):
     self.assertIsNone(PhoneNumber.get_two_way_number(phone_search))
     self.assertIsNone(PhoneNumber.get_two_way_number_by_suffix(suffix_search))
     self.assertEqual(PhoneNumber.by_owner_id(owner_id_search), [])
开发者ID:dimagi,项目名称:commcare-hq,代码行数:6,代码来源:test_phone_numbers.py

示例9: assertNoMatch

# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import by_owner_id [as 别名]
 def assertNoMatch(self, phone_search, suffix_search, owner_id_search):
     self.assertIsNone(PhoneNumber.by_phone(phone_search))
     self.assertIsNone(PhoneNumber.by_suffix(suffix_search))
     self.assertEqual(PhoneNumber.by_owner_id(owner_id_search).count(), 0)
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:6,代码来源:test_phone_numbers.py


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