當前位置: 首頁>>代碼示例>>Python>>正文


Python Notification.__unicode__方法代碼示例

本文整理匯總了Python中notification.models.Notification.__unicode__方法的典型用法代碼示例。如果您正苦於以下問題:Python Notification.__unicode__方法的具體用法?Python Notification.__unicode__怎麽用?Python Notification.__unicode__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在notification.models.Notification的用法示例。


在下文中一共展示了Notification.__unicode__方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestNotification

# 需要導入模塊: from notification.models import Notification [as 別名]
# 或者: from notification.models.Notification import __unicode__ [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.__unicode__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。