本文整理匯總了Python中airmozilla.main.models.Approval.processed方法的典型用法代碼示例。如果您正苦於以下問題:Python Approval.processed方法的具體用法?Python Approval.processed怎麽用?Python Approval.processed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類airmozilla.main.models.Approval
的用法示例。
在下文中一共展示了Approval.processed方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_event
# 需要導入模塊: from airmozilla.main.models import Approval [as 別名]
# 或者: from airmozilla.main.models.Approval import processed [as 別名]
def test_event(self):
"""Event view page loads correctly if the event is public and
scheduled and approved; request a login otherwise."""
event = Event.objects.get(title='Test event')
group = Group.objects.get()
approval = Approval(event=event, group=group)
approval.save()
event_page = reverse('main:event', kwargs={'slug': event.slug})
response_fail_approval = self.client.get(event_page)
eq_(response_fail_approval.status_code, 200)
ok_('not approved' in response_fail_approval.content)
approval.approved = True
approval.processed = True
approval.save()
response_ok = self.client.get(event_page)
eq_(response_ok.status_code, 200)
event.public = False
event.save()
response_fail = self.client.get(event_page)
self.assertRedirects(response_fail, reverse('main:login'))
event.public = True
event.status = Event.STATUS_INITIATED
event.save()
response_fail = self.client.get(event_page)
eq_(response_fail.status_code, 200)
ok_('not scheduled' in response_fail.content)
示例2: test_event
# 需要導入模塊: from airmozilla.main.models import Approval [as 別名]
# 或者: from airmozilla.main.models.Approval import processed [as 別名]
def test_event(self):
"""Event view page loads correctly if the event is public and
scheduled and approved; request a login otherwise."""
event = Event.objects.get(title="Test event")
group = Group.objects.get()
approval = Approval(event=event, group=group)
approval.save()
event_page = reverse("main:event", kwargs={"slug": event.slug})
response_fail_approval = self.client.get(event_page)
eq_(response_fail_approval.status_code, 200)
ok_("not approved" in response_fail_approval.content)
approval.approved = True
approval.processed = True
approval.save()
response_ok = self.client.get(event_page)
eq_(response_ok.status_code, 200)
event.privacy = Event.PRIVACY_COMPANY
event.save()
response_fail = self.client.get(event_page)
self.assertRedirects(response_fail, reverse("main:login"))
event.privacy = Event.PRIVACY_CONTRIBUTORS
event.save()
response_fail = self.client.get(event_page)
self.assertRedirects(response_fail, reverse("main:login"))
event.privacy = Event.PRIVACY_PUBLIC
event.status = Event.STATUS_INITIATED
event.save()
response_fail = self.client.get(event_page)
eq_(response_fail.status_code, 200)
ok_("not scheduled" in response_fail.content)
self.client.logout()
event.privacy = Event.PRIVACY_COMPANY
event.status = Event.STATUS_SCHEDULED
event.save()
response_fail = self.client.get(event_page)
self.assertRedirects(response_fail, reverse("main:login"))
nigel = User.objects.create_user("nigel", "[email protected]", "secret")
UserProfile.objects.create(user=nigel, contributor=True)
assert self.client.login(username="nigel", password="secret")
response_fail = self.client.get(event_page)
self.assertRedirects(response_fail, reverse("main:login"))
event.privacy = Event.PRIVACY_CONTRIBUTORS
event.save()
response_ok = self.client.get(event_page)
eq_(response_ok.status_code, 200)