本文整理汇总了Python中corehq.apps.sms.mixin.VerifiedNumber.get方法的典型用法代码示例。如果您正苦于以下问题:Python VerifiedNumber.get方法的具体用法?Python VerifiedNumber.get怎么用?Python VerifiedNumber.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.sms.mixin.VerifiedNumber
的用法示例。
在下文中一共展示了VerifiedNumber.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCouchSyncToSQL
# 需要导入模块: from corehq.apps.sms.mixin import VerifiedNumber [as 别名]
# 或者: from corehq.apps.sms.mixin.VerifiedNumber import get [as 别名]
def testCouchSyncToSQL(self):
self.assertEqual(self.getCouchCount(), 0)
self.assertEqual(self.getSQLCount(), 0)
# Test Create
couch_obj = VerifiedNumber()
self.setRandomCouchObjectValues(couch_obj)
couch_obj.save()
sleep(1)
self.assertEqual(self.getCouchCount(), 1)
self.assertEqual(self.getSQLCount(), 1)
sql_obj = PhoneNumber.objects.get(couch_id=couch_obj._id)
self.checkFieldValues(couch_obj, sql_obj, PhoneNumber._migration_get_fields())
self.assertTrue(VerifiedNumber.get_db().get_rev(couch_obj._id).startswith('1-'))
# Test Update
self.setRandomCouchObjectValues(couch_obj)
couch_obj.save()
sleep(1)
self.assertEqual(self.getCouchCount(), 1)
self.assertEqual(self.getSQLCount(), 1)
sql_obj = PhoneNumber.objects.get(couch_id=couch_obj._id)
self.checkFieldValues(couch_obj, sql_obj, PhoneNumber._migration_get_fields())
self.assertTrue(VerifiedNumber.get_db().get_rev(couch_obj._id).startswith('2-'))
# Test Delete
couch_id = couch_obj._id
couch_obj.delete()
with self.assertRaises(ResourceNotFound):
VerifiedNumber.get(couch_id)
self.assertEqual(self.getCouchCount(), 0)
self.assertEqual(self.getSQLCount(), 0)
示例2: _test_cache_clear
# 需要导入模块: from corehq.apps.sms.mixin import VerifiedNumber [as 别名]
# 或者: from corehq.apps.sms.mixin.VerifiedNumber import get [as 别名]
def _test_cache_clear(self, refresh_each_time=True):
"""
A test to make sure that the cache clearing is working as expected.
This test gets run twice using different values for refresh_each_time.
This makes sure that the mechanism used for clearing the cache works
whether you're updating a document you just saved or getting a document
fresh from the database and updating it.
"""
created = VerifiedNumber(
domain='phone-number-test',
owner_doc_type='CommCareCase',
owner_id='fake-owner-id1',
phone_number='99912341234',
backend_id=None,
ivr_backend_id=None,
verified=True,
contact_last_modified=datetime.utcnow()
)
created.save()
self.assertTrue(created._rev.startswith('1-'))
self.assertNoMatch('99952345234', '52345234', 'fake-owner-id2')
self.assertMatch(created, '99912341234', '12341234', 'fake-owner-id1')
# Update Phone Number
if refresh_each_time:
created = VerifiedNumber.get(created._id)
created.phone_number = '99952345234'
created.save()
self.assertTrue(created._rev.startswith('2-'))
self.assertNoMatch('99912341234', '12341234', 'fake-owner-id2')
self.assertMatch(created, '99952345234', '52345234', 'fake-owner-id1')
# Update Owner Id
if refresh_each_time:
created = VerifiedNumber.get(created._id)
created.owner_id = 'fake-owner-id2'
created.save()
self.assertTrue(created._rev.startswith('3-'))
self.assertNoMatch('99912341234', '12341234', 'fake-owner-id1')
self.assertMatch(created, '99952345234', '52345234', 'fake-owner-id2')
created.delete()
self.assertNoMatch('99952345234', '52345234', 'fake-owner-id2')
示例3: testCouchRetire
# 需要导入模块: from corehq.apps.sms.mixin import VerifiedNumber [as 别名]
# 或者: from corehq.apps.sms.mixin.VerifiedNumber import get [as 别名]
def testCouchRetire(self):
self.assertEqual(self.getCouchCount(), 0)
self.assertEqual(self.getSQLCount(), 0)
# Create
couch_obj = VerifiedNumber()
self.setRandomCouchObjectValues(couch_obj)
couch_obj.save()
sleep(1)
self.assertEqual(self.getCouchCount(), 1)
self.assertEqual(self.getSQLCount(), 1)
sql_obj = PhoneNumber.objects.get(couch_id=couch_obj._id)
self.checkFieldValues(couch_obj, sql_obj, PhoneNumber._migration_get_fields())
self.assertTrue(VerifiedNumber.get_db().get_rev(couch_obj._id).startswith('1-'))
# Test retire()
couch_obj.retire()
self.assertTrue(VerifiedNumber.get(couch_obj._id).doc_type.endswith('-Deleted'))
self.assertEqual(self.getCouchCount(), 0)
self.assertEqual(self.getSQLCount(), 0)