当前位置: 首页>>代码示例>>Python>>正文


Python UserFactory.create方法代码示例

本文整理汇总了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)))
开发者ID:danux,项目名称:django-image-dump,代码行数:13,代码来源:test_models.py

示例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())
开发者ID:danux,项目名称:django-image-dump,代码行数:11,代码来源:test_integrations.py

示例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())
开发者ID:danux,项目名称:django-image-dump,代码行数:14,代码来源:test_integrations.py

示例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'})
开发者ID:danux,项目名称:django-image-dump,代码行数:6,代码来源:test_basic_download.py

示例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'})
开发者ID:danux,项目名称:django-image-dump,代码行数:6,代码来源:test_browsing.py

示例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()
开发者ID:danux,项目名称:django-image-dump,代码行数:7,代码来源:test_delete.py


注:本文中的accounts.factories.UserFactory.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。