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


Python Notification.delete方法代码示例

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


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

示例1: TestHelperFunction

# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import delete [as 别名]
class TestHelperFunction(TestCase):
	def setUp(self):
		self.user = factory.create_user('[email protected]', '[email protected]', 'john123', 'John', 'Doe')
		self.location = factory.create_location('Thailand', 'Nakhonsawan')
		self.category = factory.create_category('Travel', 'travel')
		self.blog = factory.create_blog('Travel in Nakhonsawan', self.user, self.category, self.location)

		self.user_with_notification = factory.create_user('[email protected]', '[email protected]', 'adam123', 'Adam', 'Johnson')
		self.notification = Notification(subject=self.user_with_notification, action=1, blog=self.blog)
		self.notification.save()

	def tearDown(self):
		rm_user(self.user.id)
		rm_user(self.user_with_notification.id)
		self.notification.delete()

	def test_get_notifications(self):
		self.assertEqual(1, len(get_notifications(self.user)))
		self.assertEqual(0, len(get_notifications(self.user_with_notification)))
开发者ID:opendream,项目名称:livestory,代码行数:21,代码来源:test_views.py

示例2: TestNotification

# 需要导入模块: from notification.models import Notification [as 别名]
# 或者: from notification.models.Notification import delete [as 别名]
class TestNotification(TestCase):
	def setUp(self):
		self.user = factory.create_user('[email protected]', '[email protected]', 'john123', 'John', 'Doe')
		self.location = factory.create_location('Thailand', 'Nakhonsawan')
		self.category = factory.create_category('Travel', 'travel')
		self.blog = factory.create_blog('Travel in Nakhonsawan', self.user, self.category, self.location)

		self.love_user = factory.create_user('[email protected]', '[email protected]', 'adam123', 'Adam', 'Johnson')
		self.love_notification = Notification(subject=self.love_user, action=1, blog=self.blog)
		self.love_notification.save()

		self.download_notification = Notification(subject=self.user, action=2, blog=self.blog)
		self.download_notification.save()

	def tearDown(self):
		self.location.delete()
		self.category.delete()
		self.blog.delete()
		self.love_notification.delete()
		self.download_notification.delete()

		# UserInvitation.objects.get(email=self.love_user.email).delete()
		UserProfile.objects.get(user=self.love_user).delete()
		self.love_user.delete()

		# UserInvitation.objects.get(email=self.user.email).delete()
		UserProfile.objects.get(user=self.user).delete()
		self.user.delete()

	def test_unicode(self):
		self.assertEqual('Adam Johnson loved Travel in Nakhonsawan', self.love_notification.__unicode__())
		self.assertEqual('John Doe downloaded Travel in Nakhonsawan', self.download_notification.__unicode__())

	def test_get_action_text(self):
		self.assertEqual('loved', self.love_notification.get_action_text())
		self.assertEqual('downloaded', self.download_notification.get_action_text())
开发者ID:opendream,项目名称:livestory,代码行数:38,代码来源:test_models.py


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