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


Python UserF.create方法代码示例

本文整理汇总了Python中geokey.projects.tests.model_factories.UserF.create方法的典型用法代码示例。如果您正苦于以下问题:Python UserF.create方法的具体用法?Python UserF.create怎么用?Python UserF.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在geokey.projects.tests.model_factories.UserF的用法示例。


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

示例1: post

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
    def post(self, user, data=None):
        if user.is_anonymous and not User.objects.filter(
                display_name='AnonymousUser').exists():
            UserF.create(display_name='AnonymousUser')

        if data is None:
            data = {
                'name': 'A test image',
                'description': 'Test image description',
                'file': get_image()
            }

        url = reverse(
            'api:project_media',
            kwargs={
                'project_id': self.project.id,
                'contribution_id': self.contribution.id
            }
        )

        request = self.factory.post(url, data)
        force_authenticate(request, user)
        view = AllContributionsMediaAPIView.as_view()
        return view(
            request,
            project_id=self.project.id,
            contribution_id=self.contribution.id
        ).render()
开发者ID:oliverroick,项目名称:geokey,代码行数:30,代码来源:test_views.py

示例2: setUp

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
    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}
        )
开发者ID:tainita01,项目名称:geokey,代码行数:29,代码来源:test_views.py

示例3: setUp

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
 def setUp(self):
     self.contributor = UserF.create()
     self.admin = UserF.create()
     self.non_member = UserF.create()
     self.project = ProjectF(
         add_admins=[self.admin],
         add_contributors=[self.contributor]
     )
     self.observation = ObservationFactory.create(**{
         'project': self.project,
         'creator': self.contributor
     })
     comment = CommentFactory.create(**{
         'commentto': self.observation
     })
     response = CommentFactory.create(**{
         'commentto': self.observation,
         'respondsto': comment
     })
     CommentFactory.create(**{
         'commentto': self.observation,
         'respondsto': response
     })
     CommentFactory.create(**{
         'commentto': self.observation,
         'respondsto': comment
     })
     CommentFactory.create(**{
         'commentto': self.observation
     })
开发者ID:nagyistoce,项目名称:geokey,代码行数:32,代码来源:test_views.py

示例4: setUp

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
    def setUp(self):
        self.admin = UserF.create()
        self.contributor = UserF.create()
        self.view_member = UserF.create()
        self.non_member = UserF.create()

        self.project = ProjectF(
            add_admins=[self.admin],
            add_contributors=[self.contributor],
            add_viewers=[self.view_member]
        )
        self.category = CategoryFactory(**{
            'status': 'active',
            'project': self.project
        })

        TextFieldFactory.create(**{
            'key': 'key_1',
            'category': self.category,
            'order': 0
        })
        NumericFieldFactory.create(**{
            'key': 'key_2',
            'category': self.category,
            'order': 1
        })
开发者ID:tainita01,项目名称:geokey,代码行数:28,代码来源:test_serializers.py

示例5: setUp

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
    def setUp(self):
        self.factory = APIRequestFactory()
        self.admin = UserF.create()
        self.contributor = UserF.create()

        self.project = ProjectF.create(
            add_admins=[self.admin],
            add_contributors=[self.contributor]
        )
开发者ID:oliverroick,项目名称:geokey,代码行数:11,代码来源:test_views.py

示例6: test_get_isowner

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
    def test_get_isowner(self):
        user = UserF.create()
        comment = CommentFactory.create(**{'creator': user})

        serializer = CommentSerializer(comment, context={'user': user})
        self.assertTrue(serializer.get_isowner(comment))

        serializer = CommentSerializer(
            comment, context={'user': UserF.create()})
        self.assertFalse(serializer.get_isowner(comment))

        serializer = CommentSerializer(
            comment, context={'user': AnonymousUser()})
        self.assertFalse(serializer.get_isowner(comment))
开发者ID:tainita01,项目名称:geokey,代码行数:16,代码来源:test_serializers.py

示例7: _post

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
 def _post(self, data, user):
     if user.is_anonymous and not User.objects.filter(
             display_name='AnonymousUser').exists():
         UserF.create(display_name='AnonymousUser')
     url = reverse(
         'api:project_observations',
         kwargs={
             'project_id': self.project.id
         }
     )
     request = self.factory.post(
         url, json.dumps(data), content_type='application/json')
     force_authenticate(request, user=user)
     view = ProjectObservations.as_view()
     return view(request, project_id=self.project.id).render()
开发者ID:oliverroick,项目名称:geokey,代码行数:17,代码来源:test_views.py

示例8: test_delete_with_user

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
    def test_delete_with_user(self):
        user = UserF.create()
        view = RuleDelete.as_view()
        project = ProjectF.create(add_contributors=[user])
        grouping = GroupingFactory.create(**{'project': project})
        rule = RuleFactory.create(**{'grouping': grouping})

        url = reverse(
            'admin:rule_delete',
            kwargs={
                'project_id': project.id,
                'grouping_id': grouping.id,
                'rule_id': rule.id
            }
        )

        request = APIRequestFactory().get(url)
        request.user = user

        response = view(
            request,
            project_id=project.id,
            grouping_id=grouping.id,
            rule_id=rule.id).render()

        self.assertEqual(response.status_code, 200)
        self.assertEqual(Rule.objects.count(), 1)
        self.assertContains(
            response,
            'You are not member of the administrators group of this project '
            'and therefore not allowed to alter the settings of the project'
        )
开发者ID:tainita01,项目名称:geokey,代码行数:34,代码来源:test_views.py

示例9: test_get_with_unconnected_user

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
 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))
开发者ID:oliverroick,项目名称:geokey,代码行数:9,代码来源:test_views.py

示例10: test_post_with_user

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
    def test_post_with_user(self):
        data = {
            'name': 'test app',
            'description': '',
            'download_url': 'http://example.com/download',
            'redirect_uris': 'http://example.com/redirect',
            'authorization_grant_type': 'password'
        }

        view = ApplicationSettings.as_view()
        url = reverse('admin:app_settings', kwargs={'app_id': self.app.id})
        request = APIRequestFactory().post(url, data)
        request.user = UserF.create()
        response = view(request, app_id=self.app.id).render()
        self.assertEqual(response.status_code, 200)
        self.assertContains(
            response,
            'You are not the owner of this application and therefore not '
            'allowed to access this app.'
        )

        ref = Application.objects.get(pk=self.app.id)
        self.assertNotEqual(ref.name, data.get('name'))
        self.assertNotEqual(ref.description, data.get('description'))
        self.assertNotEqual(ref.download_url, data.get('download_url'))
        self.assertNotEqual(ref.redirect_uris, data.get('redirect_uris'))
        self.assertNotEqual(
            ref.authorization_grant_type,
            data.get('authorization_grant_type')
        )
开发者ID:oliverroick,项目名称:geokey,代码行数:32,代码来源:test_views.py

示例11: test_get_with_user

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
 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)
开发者ID:oliverroick,项目名称:geokey,代码行数:9,代码来源:test_views.py

示例12: setUp

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
 def setUp(self):
     self.user1 = UserF.create()
     self.user2 = UserF.create()
     self.app1 = ApplicationFactory(**{
         'user': self.user1
     })
     self.app2 = ApplicationFactory(**{
         'user': self.user1
     })
     self.app3 = ApplicationFactory(**{
         'user': self.user2
     })
     self.deleted_app = ApplicationFactory(**{
         'user': self.user1,
         'status': 'deleted'
     })
开发者ID:tainita01,项目名称:geokey,代码行数:18,代码来源:test_manager.py

示例13: test

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
    def test(self):
        admin = UserF.create()
        project = ProjectF(add_admins=[admin])
        observation = ObservationFactory.create(**{
            'project': project
        })
        comment = CommentFactory.create()

        factory = APIRequestFactory()
        request = factory.post(
            '/api/projects/%s/observations/%s/comments/' %
            (project.id, observation.id),
            {
                'text': 'Response to a comment',
                'respondsto': comment.id
            }
        )
        force_authenticate(request, user=admin)
        view = AllContributionsCommentsAPIView.as_view()
        response = view(
            request,
            project_id=project.id,
            observation_id=observation.id
        ).render()

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(
            json.loads(response.content).get('error'),
            'The comment you try to respond to is not a comment to the '
            'observation.'
        )
开发者ID:nagyistoce,项目名称:geokey,代码行数:33,代码来源:test_views.py

示例14: test_for_moderator

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
 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']
         )
开发者ID:oliverroick,项目名称:geokey,代码行数:10,代码来源:test_manager.py

示例15: test_for_viewer

# 需要导入模块: from geokey.projects.tests.model_factories import UserF [as 别名]
# 或者: from geokey.projects.tests.model_factories.UserF import create [as 别名]
 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']
         )
开发者ID:oliverroick,项目名称:geokey,代码行数:10,代码来源:test_manager.py


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