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


Python ContactRecordFactory.create方法代码示例

本文整理汇总了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())
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:33,代码来源:test_models.py


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