本文整理汇总了Python中mypartners.tests.factories.ContactRecordFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python ContactRecordFactory.create方法的具体用法?Python ContactRecordFactory.create怎么用?Python ContactRecordFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mypartners.tests.factories.ContactRecordFactory
的用法示例。
在下文中一共展示了ContactRecordFactory.create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_contact_record_counts_vs_list
# 需要导入模块: from mypartners.tests.factories import ContactRecordFactory [as 别名]
# 或者: from mypartners.tests.factories.ContactRecordFactory import create [as 别名]
def test_contact_record_counts_vs_list(self):
"""
ContactRecord counts for Communication Records and Referals
should match summed counts from contacts.
"""
contacts = ContactFactory.create_batch(4)
contacts[0].name = 'Other name'
contacts[1].email = '[email protected]'
contacts[2].partner = PartnerFactory(name='Other Partner')
for contact in contacts:
ContactRecordFactory.create(contact_type="job",
contact=contact,
partner=contact.partner)
ContactRecordFactory.create(contact_type = 'email',
contact=contact,
partner=contact.partner)
contacts[0].email = '[email protected]'
ContactRecordFactory.create(contact_type = 'email',
contact=contacts[0],
partner=contact.partner)
queryset = ContactRecord.objects.all()
self.assertEqual(queryset.count(), 9)
contacts = list(queryset.contacts)
sum_referrals = sum([contact['referrals'] for contact in contacts])
sum_records = sum([contact['records'] for contact in contacts])
self.assertEqual(sum_referrals, queryset.referrals)
self.assertEqual(sum_records, queryset.communication_activity.count())