本文整理汇总了Python中accounts.factories.UserFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.create方法的具体用法?Python UserFactory.create怎么用?Python UserFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.factories.UserFactory
的用法示例。
在下文中一共展示了UserFactory.create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_can_get_images_uploaded_by_a_user
# 需要导入模块: from accounts.factories import UserFactory [as 别名]
# 或者: from accounts.factories.UserFactory import create [as 别名]
def test_can_get_images_uploaded_by_a_user(self):
"""
Tests that the manager can get images specifically uploaded by a user.
"""
user_1 = UserFactory.create()
user_2 = UserFactory.create()
image_1a = ImageFactory.create(uploaded_by=user_1)
image_1b = ImageFactory.create(uploaded_by=user_1)
image_2a = ImageFactory.create(uploaded_by=user_2)
self.assertEquals([image_1b, image_1a], list(Image.objects.filter_uploaded_by(user_1)))
self.assertEquals([image_2a], list(Image.objects.filter_uploaded_by(user_2)))
示例2: test_can_logout
# 需要导入模块: from accounts.factories import UserFactory [as 别名]
# 或者: from accounts.factories.UserFactory import create [as 别名]
def test_can_logout(self):
"""
Tests the logout view.
"""
user = UserFactory.create()
self.client.login(**{'username': user.username, 'password': 'password'})
response = self.client.get(reverse('accounts:logout'), follow=True)
self.assertRedirects(response, '{0}?next={1}'.format(reverse('accounts:login'), reverse('images:upload')))
self.assertFalse(response.context['user'].is_authenticated())
示例3: test_can_login_and_redirect
# 需要导入模块: from accounts.factories import UserFactory [as 别名]
# 或者: from accounts.factories.UserFactory import create [as 别名]
def test_can_login_and_redirect(self):
"""
Tests a user can login and be redirected back to the homepage.
"""
user = UserFactory.create()
response = self.client.post(
reverse('accounts:login'),
data={'username': user.username, 'password': 'password'},
follow=True,
)
self.assertRedirects(response, reverse('images:upload'))
self.assertTrue(response.context['user'].is_authenticated())
示例4: setUp
# 需要导入模块: from accounts.factories import UserFactory [as 别名]
# 或者: from accounts.factories.UserFactory import create [as 别名]
def setUp(self):
super(DownloadTestCase, self).setUp()
self.user = UserFactory.create()
self.client.login(**{'username': self.user.username, 'password': 'password'})
示例5: setUp
# 需要导入模块: from accounts.factories import UserFactory [as 别名]
# 或者: from accounts.factories.UserFactory import create [as 别名]
def setUp(self):
super(YoutubeVideoBrowsingTestCase, self).setUp()
self.user = UserFactory.create()
self.client.login(**{'username': self.user.username, 'password': 'password'})
示例6: setUp
# 需要导入模块: from accounts.factories import UserFactory [as 别名]
# 或者: from accounts.factories.UserFactory import create [as 别名]
def setUp(self):
super(DeleteImageTestCase, self).setUp()
user = UserFactory.create()
self.client.login(**{'username': user.username, 'password': 'password'})
self.image = ImageFactory()