本文整理汇总了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)
示例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()