本文整理汇总了Python中newsletter.models.Subscription.unsubscribed方法的典型用法代码示例。如果您正苦于以下问题:Python Subscription.unsubscribed方法的具体用法?Python Subscription.unsubscribed怎么用?Python Subscription.unsubscribed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类newsletter.models.Subscription
的用法示例。
在下文中一共展示了Subscription.unsubscribed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unsubscribe_view
# 需要导入模块: from newsletter.models import Subscription [as 别名]
# 或者: from newsletter.models.Subscription import unsubscribed [as 别名]
def test_unsubscribe_view(self):
""" Test the unsubscription form. """
subscription = Subscription(user=self.user, newsletter=self.n)
subscription.subscribed = True
subscription.unsubscribed = False
subscription.save()
self.assertLessThan(
subscription.subscribe_date, timezone.now() + timedelta(seconds=1)
)
response = self.client.get(self.unsubscribe_url)
self.assertContains(response, self.n.title, status_code=200)
self.assertEqual(response.context['newsletter'], self.n)
self.assertEqual(response.context['user'], self.user)
self.assertContains(
response, 'action="%s"' % self.unsubscribe_confirm_url)
self.assertContains(response, 'id="id_submit"')
subscription = self.get_user_subscription()
self.assertTrue(subscription.subscribed)
self.assertFalse(subscription.unsubscribed)
示例2: test_subscribe_twice
# 需要导入模块: from newsletter.models import Subscription [as 别名]
# 或者: from newsletter.models.Subscription import unsubscribed [as 别名]
def test_subscribe_twice(self):
# After subscribing we should not be able to subscribe again
subscription = Subscription(user=self.user, newsletter=self.n)
subscription.subscribed = True
subscription.unsubscribed = False
subscription.save()
response = self.client.get(self.subscribe_url)
self.assertContains(response, self.n.title, status_code=200)
self.assertEqual(response.context['newsletter'], self.n)
self.assertEqual(response.context['user'], self.user)
self.assertNotContains(
response, 'action="%s"' % self.subscribe_confirm_url)
self.assertNotContains(response, 'id="id_submit"')