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


Python Contact.delete方法代码示例

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


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

示例1: test_signal_processor

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import delete [as 别名]
    def test_signal_processor(self):
        contact = Contact(
            first_name='Igor_test',
            last_name='Kucher_test',
            birth_date='1990-01-10',
            email='[email protected]',
            jabber='[email protected]',
            skype='skype_test',
            other_contacts='other_test',
            bio='bio_test'
        )
        contact.save()

        contact_object_name = ContentType.objects.get_for_model(contact).model

        log_entry = ModelsChangeLog.objects.latest()
        self.assertEqual(log_entry.model, contact_object_name.title())
        self.assertEqual(log_entry.action, ModelsChangeLog.CREATE)
        self.assertEqual(log_entry.object_id, contact.pk)

        contact.first_name = 'Igor_test_edit'
        contact.save()
        log_entry = ModelsChangeLog.objects.latest()
        self.assertEqual(log_entry.model, contact_object_name.title())
        self.assertEqual(log_entry.action, ModelsChangeLog.EDIT)
        self.assertEqual(log_entry.object_id, contact.pk)

        contact_pk = contact.pk
        contact.delete()
        log_entry = ModelsChangeLog.objects.latest('created')
        self.assertEqual(log_entry.model, contact_object_name.title())
        self.assertEqual(log_entry.action, ModelsChangeLog.DELETE)
        self.assertEqual(log_entry.object_id, contact_pk)
开发者ID:crash-843,项目名称:test42,代码行数:35,代码来源:tests.py

示例2: test_model_contact

# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import delete [as 别名]
 def test_model_contact(self):
     """Test Contact model"""
     type = ContactType(name='Test', slug='test')
     type.save()
     obj = Contact(name='Test', contact_type=type)
     obj.save()
     self.assertEquals('Test', obj.name)
     self.assertNotEquals(obj.id, None)
     obj.delete()
开发者ID:tovmeod,项目名称:anaf,代码行数:11,代码来源:tests.py


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