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


Python factories.UserFactory类代码示例

本文整理汇总了Python中utils.factories.UserFactory的典型用法代码示例。如果您正苦于以下问题:Python UserFactory类的具体用法?Python UserFactory怎么用?Python UserFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UserFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

 def setUp(self):
     book = factories.BookFactory.create()
     user = UserFactory.create(username='phildini')
     bookowner = factories.BookOwnerFactory.create(user=user,book=book)
     contact = factories.ContactFactory(book=book)
     request_factory = RequestFactory()
     request = request_factory.get(contact.get_absolute_url())
     request.user = UserFactory.create()
     self.response = views.contact_views.ContactListView.as_view()(request)
开发者ID:paulproteus,项目名称:logtacts,代码行数:9,代码来源:test_views.py

示例2: setUp

 def setUp(self):
     book = factories.BookFactory.create()
     self.user = UserFactory.create(username='phildini')
     bookowner = factories.BookOwnerFactory.create(user=self.user,book=book)
     self.contact = factories.ContactFactory.create(book=book)
     request_factory = RequestFactory()
     self.request = request_factory.get(self.contact.get_absolute_url())
开发者ID:clach04,项目名称:logtacts,代码行数:7,代码来源:test_views.py

示例3: test_contact_detail_view_404_wrong_user

 def test_contact_detail_view_404_wrong_user(self):
     self.request.user = UserFactory.create()
     with self.assertRaises(Http404):
         views.contact_views.ContactView.as_view()(
             self.request,
             pk=self.contact.pk,
         )
开发者ID:clach04,项目名称:logtacts,代码行数:7,代码来源:test_views.py

示例4: test_tag_create_view_bad_book

 def test_tag_create_view_bad_book(self):
     request = self.factory.post('/api/tags/', {'tag': 'Test tag', 'book': str(self.book.id)}, format='json')
     user = UserFactory.create(username='nicholle')
     force_authenticate(request, user=user)
     view = views.TagListCreateAPIView.as_view()
     response = view(request)
     response.render()
     self.assertEqual(response.status_code, 401)
开发者ID:paulproteus,项目名称:logtacts,代码行数:8,代码来源:test_api.py

示例5: setUp

 def setUp(self):
     self.factory = APIRequestFactory()
     self.book = factories.BookFactory.create()
     self.user = UserFactory.create(username='phildini')
     bookowner = factories.BookOwnerFactory.create(
         book=self.book,
         user=self.user,
     )
开发者ID:neynah,项目名称:logtacts,代码行数:8,代码来源:test_api_views.py

示例6: test_tag_list_view_wrong_user_for_book

 def test_tag_list_view_wrong_user_for_book(self):
     tag = factories.TagFactory.create(book=self.book)
     request = self.factory.get('/api/tags/', format='json')
     user = UserFactory.create(username='asheesh')
     force_authenticate(request, user=user)
     response = views.TagListCreateAPIView.as_view()(request)
     response.render()
     self.assertEqual(response.status_code, 200)
     self.assertEqual(len(response.data), 0)
开发者ID:neynah,项目名称:logtacts,代码行数:9,代码来源:test_api_views.py

示例7: test_log_delete_view_401_if_wrong_user

 def test_log_delete_view_401_if_wrong_user(self):
     self.request = self.request_factory.get(
         reverse('log-delete', kwargs={'pk': self.log.id})
     )
     self.request.user = UserFactory.create()
     with self.assertRaises(PermissionDenied):
         views.log_views.DeleteLogView.as_view()(
             self.request,
             pk=self.log.pk,
         )
开发者ID:clach04,项目名称:logtacts,代码行数:10,代码来源:test_views.py

示例8: test_tagged_list_view_401_if_wrong_user

 def test_tagged_list_view_401_if_wrong_user(self):
     request = self.request_factory.get(
         reverse('contacts-tagged', kwargs={'pk': self.tag.id})
     )
     request.user = UserFactory.create()
     with self.assertRaises(Http404):
         views.contact_views.TaggedContactListView.as_view()(
             request,
             pk=self.tag.pk,
         )
开发者ID:clach04,项目名称:logtacts,代码行数:10,代码来源:test_views.py

示例9: test_log_list_view_wrong_user_for_book

 def test_log_list_view_wrong_user_for_book(self):
     request = self.factory.get(self.url, format='json')
     user = UserFactory.create(username='asheesh')
     force_authenticate(request, user=user)
     response = views.LogListCreateAPIView.as_view()(
         request,
         pk=self.contact.id,
     )
     response.render()
     self.assertEqual(response.status_code, 404)
开发者ID:neynah,项目名称:logtacts,代码行数:10,代码来源:test_api_views.py

示例10: test_log_edit_view_401_if_right_user

 def test_log_edit_view_401_if_right_user(self):
     self.request = self.request_factory.get(
         reverse('log-edit', kwargs={'pk': self.log.id})
     )
     self.request.user = UserFactory.create()
     with self.assertRaises(PermissionDenied):
         views.log_views.EditLogView.as_view()(
             self.request,
             pk=self.log.pk,
         )
开发者ID:clach04,项目名称:logtacts,代码行数:10,代码来源:test_views.py

示例11: test_contact_create_view_wrong_book_for_user

 def test_contact_create_view_wrong_book_for_user(self):
     request = self.factory.post(
         '/api/contacts/',
         {'name': 'Philip', 'book': str(self.book.id)},
         format='json',
     )
     user = UserFactory.create(username='asheesh')
     force_authenticate(request, user=user)
     response = views.ContactListCreateAPIView.as_view()(request)
     response.render()
     self.assertEqual(response.status_code, 401)
开发者ID:neynah,项目名称:logtacts,代码行数:11,代码来源:test_api_views.py

示例12: test_log_create_view_wrong_book_for_user

 def test_log_create_view_wrong_book_for_user(self):
     request = self.factory.post(
         '/api/contacts/',
         {'contact': str(self.contact.id)},
         format='json',
     )
     user = UserFactory.create(username='asheesh')
     force_authenticate(request, user=user)
     response = views.LogListCreateAPIView.as_view()(
         request,
         pk=self.contact.id,
     )
     response.render()
     self.assertEqual(response.status_code, 404)
开发者ID:neynah,项目名称:logtacts,代码行数:14,代码来源:test_api_views.py

示例13: test_contact_detail_raises_404_if_wrong_user

 def test_contact_detail_raises_404_if_wrong_user(self):
     contact = factories.ContactFactory.create(book=self.book)
     request = self.factory.get(
         '/api/contacts/{}'.format(contact.pk),
         format='json',
     )
     user = UserFactory.create(username="asheesh")
     force_authenticate(request, user=user)
     response = views.ContactDetailEditAPIView.as_view()(
         request,
         pk=contact.id,
     )
     response.render()
     self.assertEqual(response.status_code, 404)
开发者ID:neynah,项目名称:logtacts,代码行数:14,代码来源:test_api_views.py

示例14: test_contact_list_view_contains_only_what_it_should

 def test_contact_list_view_contains_only_what_it_should(self):
     book = factories.BookFactory.create()
     user = UserFactory.create(username='nicholle')
     factories.BookOwnerFactory.create(book=book, user=user)
     good_contact = factories.ContactFactory.create(book=book)
     bad_contact = factories.ContactFactory.create()
     good_tag = factories.TagFactory.create(book=book)
     bad_tag = factories.TagFactory.create()
     good_contact.tags.add(good_tag)
     request_factory = RequestFactory()
     request = request_factory.get(reverse('contacts-list'))
     request.user = user
     response = views.contact_views.ContactListView.as_view()(request)
     self.assertEqual(len(response.context_data.get('tags')), 1)
     self.assertEqual(len(response.context_data.get('contact_list')), 1)
     self.assertEqual(response.context_data.get('tags')[0], good_tag)
     self.assertEqual(
         response.context_data.get('contact_list')[0], good_contact,
     )
开发者ID:clach04,项目名称:logtacts,代码行数:19,代码来源:test_views.py

示例15: test_review_user_view_200

 def test_review_user_view_200(self):
     user = UserFactory.create()
     user.is_staff = True
     self.request.user = user
     response = ReviewUserView.as_view()(self.request)
     self.assertEqual(response.status_code, 200)
开发者ID:clach04,项目名称:logtacts,代码行数:6,代码来源:test_views.py


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