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


Python UserF.create方法代码示例

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


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

示例1: test_post_image_file_save

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
    def test_post_image_file_save(self):
        observation = ObservationFactory()
        video_file = VideoFile.objects.create(
            name='Test name',
            description='Test Description',
            contribution=observation,
            creator=UserF.create(),
            video=get_image(),
            youtube_link='http://example.com/1122323',
            swf_link='http://example.com/1122323.swf'
        )
        VideoFile.objects.create(
            status='deleted',
            name='Test name',
            description='Test Description',
            contribution=observation,
            creator=UserF.create(),
            video=get_image(),
            youtube_link='http://example.com/1122323',
            swf_link='http://example.com/1122323.swf'
        )

        post_save_media_file_update(VideoFile, instance=video_file)
        self.assertEqual(video_file.contribution.num_media, 1)
        self.assertEqual(video_file.contribution.num_comments, 0)
开发者ID:nagyistoce,项目名称:geokey,代码行数:27,代码来源:test_model.py

示例2: test_with_inactive_project

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
    def test_with_inactive_project(self):
        admin = UserF.create()
        email_user = UserF.create()

        project = ProjectF.create(
            add_admins=[admin],
            **{'status': 'inactive'}
        )

        view = ProjectContactAdmins.as_view()
        url = reverse(
            'api:project_contact_admins',
            kwargs={
                'project_id': project.id
            }
        )
        request = APIRequestFactory().post(
            url,
            json.dumps({'email_text': 'Blah Blah'}),
            content_type='application/json'
        )
        force_authenticate(request, user=email_user)

        response = view(request, project_id=project.id).render()
        self.assertEqual(response.status_code, 404)
        self.assertEquals(len(mail.outbox), 0)
开发者ID:nagyistoce,项目名称:geokey,代码行数:28,代码来源:test_views.py

示例3: setUp

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

        self.public_project = ProjectF.create(
            add_admins=[self.admin],
            add_contributors=[self.contributor],
            **{
                'isprivate': False
            }
        )

        self.private_project = ProjectF.create(
            add_admins=[self.admin],
            add_contributors=[self.contributor]
        )

        self.inactive_project = ProjectF.create(
            add_admins=[self.admin],
            add_contributors=[self.contributor],
            **{
                'status': 'inactive'
            }
        )

        self.deleted_project = ProjectF.create(
            add_admins=[self.admin],
            add_contributors=[self.contributor],
            **{'isprivate': False}
        )
        self.deleted_project.delete()
开发者ID:oliverroick,项目名称:geokey,代码行数:35,代码来源:test_views.py

示例4: test

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
    def test(self):
        admin = UserF.create()
        project = ProjectF.create(add_admins=[admin])
        category_1 = CategoryFactory(**{'project': project})
        TextFieldFactory(**{
            'key': 'text',
            'category': category_1
        })
        category_2 = CategoryFactory(**{'project': project})
        TextFieldFactory(**{
            'key': 'bla',
            'category': category_2
        })

        ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_1,
            'properties': {'text': 'yes'}}
        )

        viewer = UserF.create()
        view = GroupingFactory(add_viewers=[viewer], **{'project': project})
        RuleFactory(**{
            'grouping': view,
            'category': category_1,
            'constraints': {'text': 'yes'}
        })

        serializer = GroupingSerializer(view, context={'user': admin})
        self.assertEqual(len(serializer.get_data(view).get('features')), 5)
        self.assertEqual(serializer.get_num_contributions(view), 5)
开发者ID:tainita01,项目名称:geokey,代码行数:33,代码来源:test_serializer.py

示例5: test_all_contacts

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

        project = ProjectF.create(
            add_admins=[admin],
            add_contributors=[contributor]
        )

        project.contact_admins(email_user, 'Test email')
        # Should be 2 because project creator is admin too
        self.assertEquals(len(mail.outbox), 2)
开发者ID:tainita01,项目名称:geokey,代码行数:15,代码来源:test_models.py

示例6: test_post_with_user

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
    def test_post_with_user(self):
        factory = APIRequestFactory()
        user = UserF.create(**{'is_superuser': False})
        user_to_add = UserF.create(**{'is_superuser': False})
        request = factory.post(
            reverse('ajax:superusers_adduser'),
            {'userId': user_to_add.id}
        )
        force_authenticate(request, user=user)
        view = AddSuperUsersAjaxView.as_view()
        response = view(request).render()

        self.assertEqual(response.status_code, 403)
        self.assertEqual(len(User.objects.filter(is_superuser=True)), 0)
开发者ID:oliverroick,项目名称:geokey,代码行数:16,代码来源:test_views.py

示例7: test_get_data_text_filter

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
    def test_get_data_text_filter(self):
        admin = UserF.create()
        project = ProjectF.create(add_admins=[admin])
        category_1 = CategoryFactory(**{'project': project})
        TextFieldFactory(**{
            'key': 'text',
            'category': category_1
        })
        category_2 = CategoryFactory(**{'project': project})
        TextFieldFactory(**{
            'key': 'bla',
            'category': category_2
        })

        for x in range(0, 5):
            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'properties': {'text': 'yes ' + str(x)}}
            )

            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'status': 'pending',
                'properties': {'text': 'yes ' + str(x)}}
            )

            ObservationFactory.create(**{
                'project': project,
                'category': category_1,
                'properties': {'text': 'no ' + str(x)}}
            )

            ObservationFactory.create(**{
                'project': project,
                'category': category_2,
                'properties': {'bla': 'yes ' + str(x)}}
            )

        viewer = UserF.create()
        view = GroupingFactory(add_viewers=[viewer], **{'project': project})
        RuleFactory(**{
            'grouping': view,
            'category': category_1,
            'constraints': {'text': 'yes'}
        })
        self.assertEqual(view.data(admin).count(), 10)
        self.assertEqual(view.data(viewer).count(), 5)
开发者ID:tainita01,项目名称:geokey,代码行数:51,代码来源:test_model.py

示例8: test_delete_with_user

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
    def test_delete_with_user(self):
        factory = APIRequestFactory()
        user = UserF.create(**{'is_superuser': False})
        user_to_remove = UserF.create(**{'is_superuser': True})
        request = factory.delete(
            reverse('ajax:superusers_deleteuser', kwargs={
                'user_id': user_to_remove.id
            })
        )
        force_authenticate(request, user=user)
        view = DeleteSuperUsersAjaxView.as_view()
        response = view(request, user_id=user_to_remove.id).render()

        self.assertEqual(response.status_code, 403)
        self.assertEqual(len(User.objects.filter(is_superuser=True)), 1)
开发者ID:oliverroick,项目名称:geokey,代码行数:17,代码来源:test_views.py

示例9: test_category_serialization

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
    def test_category_serialization(self):
        user = UserF.create()

        project = ProjectF.create(
            add_admins=[user]
        )
        CategoryFactory.create(**{'project': project})
        CategoryFactory.create(
            **{'project': project, 'status': 'inactive'}
        )
        o1 = CategoryFactory.create(**{'project': project})
        TextFieldFactory.create(**{'category': o1})
        o2 = CategoryFactory.create(**{'project': project})
        TextFieldFactory.create(**{'category': o2})

        request = self.factory.get(
            '/api/projects/%s/' % project.id)
        force_authenticate(request, user=user)
        view = SingleProject.as_view()
        response = view(request, project_id=project.id).render()

        self.assertEqual(response.status_code, 200)
        self.assertEqual(
            2,
            len(json.loads(response.content).get('categories'))
        )
开发者ID:oliverroick,项目名称:geokey,代码行数:28,代码来源:test_views.py

示例10: test_post_with_user

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
    def test_post_with_user(self):
        """
        Updating with normal user should render the page with an error message
        """
        user = UserF.create()
        subset = SubsetFactory.create()

        self.request.user = user
        self.request.method = 'POST'
        self.request.POST = {
            'name': 'Name',
            'description': 'Description',
        }

        response = self.view(
            self.request,
            project_id=subset.project.id,
            subset_id=subset.id).render()

        rendered = render_to_string(
            'subsets/subsets_settings.html',
            {
                'error_description': 'Project matching query does not exist.',
                'error': 'Not found.',
                'user': user,
                'PLATFORM_NAME': get_current_site(self.request).name,
                'GEOKEY_VERSION': version.get_version()
            }
        )
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content.decode('utf-8'), rendered)

        reference = Subset.objects.get(pk=subset.id)
        self.assertNotEqual(reference.name, 'Name')
        self.assertNotEqual(reference.description, 'Description')
开发者ID:nagyistoce,项目名称:geokey,代码行数:37,代码来源:test_views.py

示例11: test_get_with_superuser

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
 def test_get_with_superuser(self):
     view = PlatformSettings.as_view()
     url = reverse('admin:superuser_index')
     request = APIRequestFactory().get(url)
     request.user = UserF.create(**{'is_superuser': True})
     response = view(request).render()
     self.assertEqual(response.status_code, 200)
开发者ID:oliverroick,项目名称:geokey,代码行数:9,代码来源:test_views.py

示例12: test_post_with_superuser

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
    def test_post_with_superuser(self):
        user = UserF.create(**{'is_superuser': True})
        self.create_inactive()
        self.request.POST = QueryDict(
            'activate_users=%s&activate_users=%s' % (
                self.inactive_1.id, self.inactive_2.id))
        self.request.method = 'POST'
        self.request.user = user

        response = self.view(self.request).render()

        rendered = render_to_string(
            'superusertools/manage_inactiveusers.html',
            {
                'inactive_users': [self.inactive_3],
                'user': user,
                'PLATFORM_NAME': get_current_site(self.request).name,
                'GEOKEY_VERSION': version.get_version(),
                'messages': get_messages(self.request)
            }
        )
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content.decode('utf-8'), rendered)
        self.assertEqual(
            User.objects.filter(is_active=False).count(), 1
        )
        self.assertEqual(
            EmailAddress.objects.filter(verified=False).count(), 1
        )
开发者ID:oliverroick,项目名称:geokey,代码行数:31,代码来源:test_views.py

示例13: test_get_data_with_none_rule

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
    def test_get_data_with_none_rule(self):
        user = UserF.create()
        project = ProjectF.create()
        category_1 = CategoryFactory(**{'project': project})
        category_2 = CategoryFactory(**{'project': project})
        category_3 = CategoryFactory(**{'project': project})

        UserGroupF.create(
            add_users=[user],
            **{'project': project, 'filters': None}
        )

        ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_1}
        )
        ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_2}
        )
        ObservationFactory.create_batch(5, **{
            'project': project,
            'category': category_3}
        )

        self.assertEqual(project.get_all_contributions(user).count(), 15)
开发者ID:nagyistoce,项目名称:geokey,代码行数:28,代码来源:test_models.py

示例14: test_get_with_user

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
 def test_get_with_user(self):
     view = ProjectCreate.as_view()
     url = reverse('admin:project_create')
     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

示例15: test_get_with_user

# 需要导入模块: from geokey.users.tests.model_factories import UserF [as 别名]
# 或者: from geokey.users.tests.model_factories.UserF import create [as 别名]
    def test_get_with_user(self):
        """
        Accessing the view with normal user should render the page with an
        error message
        """
        subset = SubsetFactory.create()
        user = UserF.create()

        self.request.user = user
        response = self.view(
            self.request,
            project_id=subset.project.id,
            subset_id=subset.id).render()

        rendered = render_to_string(
            'base.html',
            {
                'error_description': 'Project matching query does not exist.',
                'error': 'Not found.',
                'user': user,
                'PLATFORM_NAME': get_current_site(self.request).name,
                'GEOKEY_VERSION': version.get_version()
            }
        )
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content.decode('utf-8'), rendered)
        self.assertEqual(Subset.objects.count(), 1)
开发者ID:nagyistoce,项目名称:geokey,代码行数:29,代码来源:test_views.py


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