本文整理汇总了Python中myjobs.tests.factories.UserFactory.is_disabled方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.is_disabled方法的具体用法?Python UserFactory.is_disabled怎么用?Python UserFactory.is_disabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myjobs.tests.factories.UserFactory
的用法示例。
在下文中一共展示了UserFactory.is_disabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_not_disabled
# 需要导入模块: from myjobs.tests.factories import UserFactory [as 别名]
# 或者: from myjobs.tests.factories.UserFactory import is_disabled [as 别名]
def test_not_disabled(self):
"""
An anonymous user who provides the :verify: query string or
user with is_disabled set to True should be redirected to the home
page. An anonymous user who does not should see a 404. A user with
is_active set to False should proceed to their destination.
"""
client = TestClient()
user = UserFactory()
#Anonymous user
resp = client.get(reverse('view_profile'))
path = resp.request.get('PATH_INFO')
self.assertRedirects(resp, reverse('home') + '?next=' + path)
# This is ugly, but it is an artifact of the way Django redirects
# users who fail the `user_passes_test` decorator.
qs = '?verify=%s' % user.user_guid
next_qs = '?next=' + urlquote('/profile/view/%s' % qs)
# Anonymous user navigates to url with :verify: in query string
resp = client.get(reverse('view_profile') + qs)
# Old path + qs is urlquoted and added to the url as the :next: param
self.assertRedirects(resp, "http://testserver/" + next_qs)
# Active user
client.login_user(user)
resp = client.get(reverse('view_profile'))
self.assertTrue(resp.status_code, 200)
#Disabled user
user.is_disabled = True
user.save()
resp = client.get(reverse('view_profile'))
self.assertRedirects(resp, "http://testserver/?next=/profile/view/")