本文整理汇总了Python中projects.tests.model_factories.UserF类的典型用法代码示例。如果您正苦于以下问题:Python UserF类的具体用法?Python UserF怎么用?Python UserF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserF类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.factory = APIRequestFactory()
self.admin = UserF.create()
self.creator = UserF.create()
self.viewer = UserF.create()
self.project = ProjectF(
add_admins=[self.admin],
add_contributors=[self.creator]
)
self.contribution = ObservationFactory.create(
**{'project': self.project, 'creator': self.creator}
)
self.viewer = UserF.create()
self.grouping = GroupingFactory.create(
add_viewers=[self.viewer],
**{'project': self.project}
)
RuleFactory.create(**{
'grouping': self.grouping,
'category': self.contribution.category
})
self.image_file = ImageFileFactory.create(
**{'contribution': self.contribution, 'creator': self.creator}
)
示例2: test
def test(self):
creator = UserF.create()
admin = UserF.create()
project = ProjectF(add_admins=[admin])
observation = ObservationFactory.create(**{
'project': project,
'creator': creator
})
comment = CommentFactory.create()
factory = APIRequestFactory()
url = reverse('api:myobservations_single_comment', kwargs={
'project_id': project.id,
'observation_id': observation.id,
'comment_id': comment.id
})
request = factory.delete(url)
force_authenticate(request, user=admin)
view = MyContributionsSingleCommentAPIView.as_view()
response = view(
request,
project_id=project.id,
observation_id=observation.id,
comment_id=comment.id
).render()
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
示例3: setUp
def setUp(self):
self.factory = RequestFactory()
self.admin = UserF.create()
self.contributor = UserF.create()
self.non_member = UserF.create()
self.project = ProjectF.create(
add_admins=[self.admin],
add_contributors=[self.contributor]
)
示例4: setUp
def setUp(self):
self.factory = APIRequestFactory()
self.admin = UserF.create()
self.contributor = UserF.create()
self.non_member = UserF.create()
self.project = ProjectF(
add_admins=[self.admin],
add_contributors=[self.contributor]
)
self.view = GroupingFactory(**{
'project': self.project,
'description': 'description'
})
示例5: test_get_with_unconnected_user
def test_get_with_unconnected_user(self):
view = ApplicationDisconnect.as_view()
url = reverse('admin:app_disconnect', kwargs={'app_id': self.app.id})
request = APIRequestFactory().get(url)
request.user = UserF.create()
response = view(request, app_id=self.app.id)
self.assertTrue(isinstance(response, HttpResponseRedirect))
示例6: setUp
def setUp(self):
self.user1 = UserF.create()
self.user2 = UserF.create()
self.app1 = ApplicationFactory(**{
'creator': self.user1
})
self.app2 = ApplicationFactory(**{
'creator': self.user1
})
self.app3 = ApplicationFactory(**{
'creator': self.user2
})
self.deleted_app = ApplicationFactory(**{
'creator': self.user1,
'status': 'deleted'
})
示例7: test_add_comment_to_observation_with_view_member
def test_add_comment_to_observation_with_view_member(self):
view_member = UserF.create()
GroupingFactory(add_viewers=[view_member], **{
'project': self.project
})
response = self.get_response(view_member)
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
示例8: test_get_with_user
def test_get_with_user(self):
view = ApplicationOverview.as_view()
url = reverse('admin:app_overview')
request = APIRequestFactory().get(url)
request.user = UserF.create()
response = view(request).render()
self.assertEqual(response.status_code, 200)
示例9: test_for_viewer
def test_for_viewer(self):
observations = Observation.objects.all().for_viewer(UserF.create())
self.assertEqual(len(observations), 5)
for observation in observations:
self.assertNotIn(
observation.status,
['draft', 'pending', 'deleted']
)
示例10: test_for_moderator
def test_for_moderator(self):
observations = Observation.objects.all().for_moderator(UserF.create())
self.assertEqual(len(observations), 10)
for observation in observations:
self.assertNotIn(
observation.status,
['draft', 'deleted']
)
示例11: setUp
def setUp(self):
self.user = UserF.create()
self.app = ApplicationFactory.create()
self.token = AccessToken.objects.create(
user=self.user,
client=self.app.client,
token='df0af6a395b4cd072445b3832e9379bfee257da0',
scope=1
)
示例12: setUp
def setUp(self):
self.creator = UserF.create()
ObservationFactory.create_batch(
5, **{'status': 'active', 'creator': self.creator})
ObservationFactory.create_batch(
5, **{'status': 'draft', 'creator': self.creator})
ObservationFactory.create_batch(
5, **{'status': 'pending', 'creator': self.creator})
ObservationFactory.create_batch(
5, **{'status': 'deleted', 'creator': self.creator})
示例13: test_delete_image_with_viewer
def test_delete_image_with_viewer(self):
viewer = UserF.create()
dataview = GroupingFactory.create(
add_viewers=[viewer],
**{'project': self.project}
)
RuleFactory.create(**{
'grouping': dataview,
'category': self.contribution.category
})
response = self.delete(viewer)
self.assertEqual(response.status_code, 404)