• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tests.GroupFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_group_edit

 def test_group_edit(self):
     # Curator can edit a group and change (some of) its properties
     data = {
         "name": u"Test Group",
         "accepting_new_members": u"by_request",
         "description": u"lorem ipsum and lah-dee-dah",
         "irc_channel": u"some text, this is not validated",
         "website": u"http://mozillians.org",
         "wiki": u"http://wiki.mozillians.org",
         "members_can_leave": True,
         "visible": True,
         "functional_area": False,
     }
     group = GroupFactory(**data)
     # Must be curator or superuser to edit group. Make user the curator.
     group.curator = self.user.userprofile
     group.save()
     url = reverse("groups:group_edit", prefix="/en-US/", kwargs={"url": group.url})
     # Change some data
     data2 = data.copy()
     data2["description"] = u"A new description"
     data2["wiki"] = u"http://google.com/"
     # make like a form
     del data2["functional_area"]
     with self.login(self.user) as client:
         response = client.post(url, data=data2, follow=False)
     eq_(302, response.status_code)
     group = GroupAlias.objects.get(name=data["name"]).alias
     eq_(data2["description"], group.description)
     ok_(group.visible)
     ok_(group.members_can_leave)
     ok_(not group.functional_area)
开发者ID:venksv,项目名称:mozillians,代码行数:32,代码来源:test_views_misc.py


示例2: test_member_counts

    def test_member_counts(self):
        # The Group admin computes how many vouched members there are
        # and how many overall

        # IMPORTANT: This test is expected to fail on Postgres, and
        # probably other databases where the Boolean type is not just
        # an alias for a small integer. Mozillians is currently
        # deployed on a database where this works. If we ever try
        # deploying it on another database where it doesn't work, this
        # test will alert us quickly that we'll need to take another
        # approach to this feature.

        # Create group with 1 vouched member and 1 unvouched member
        group = GroupFactory()
        user = UserFactory(userprofile={'is_vouched': False})
        group.add_member(user.userprofile)
        user2 = UserFactory(userprofile={'is_vouched': True})
        group.add_member(user2.userprofile)

        admin = GroupAdmin(model=Group, admin_site=site)
        mock_request = Mock(spec=HttpRequest)
        qset = admin.queryset(mock_request)

        g = qset.get(name=group.name)
        eq_(2, g.member_count)
        eq_(1, g.vouched_member_count)
开发者ID:Chinmay26,项目名称:mozillians,代码行数:26,代码来源:test_admin.py


示例3: test_update_basket_task_without_token

    def test_update_basket_task_without_token(self, basket_mock, lookup_token_mock, request_mock):
        lookup_token_mock.return_value = "basket_token"

        user = UserFactory.create(userprofile={'is_vouched': True,
                                               'country': 'gr',
                                               'city': 'athens'})
        group = GroupFactory.create(
            name='Web Development', steward=user.userprofile)
        GroupFactory.create(name='Marketing', steward=user.userprofile)
        group.members.add(user.userprofile)
        data = {'country': 'gr',
                'city': 'athens',
                'WEB_DEVELOPMENT': 'Y',
                'MARKETING': 'N'}

        basket_mock.subscribe.return_value = {}

        update_basket_task(user.userprofile.id)

        basket_mock.subscribe.assert_called_with(
            user.email, 'newsletter', trigger_welcome='N')
        request_mock.assert_called_with(
            'post', 'custom_update_phonebook', token='basket_token', data=data)
        ok_(UserProfile.objects.filter(
            basket_token='basket_token', id=user.userprofile.id).exists())
开发者ID:Narrator,项目名称:mozillians,代码行数:25,代码来源:test_tasks.py


示例4: test_set_membership_group_matches_alias

 def test_set_membership_group_matches_alias(self):
     group_1 = GroupFactory.create(name="foo")
     group_2 = GroupFactory.create(name="lo")
     GroupAliasFactory.create(alias=group_2, name="bar")
     user = UserFactory.create()
     user.userprofile.set_membership(Group, ["foo", "bar"])
     eq_(set(user.userprofile.groups.all()), set([group_1, group_2]))
开发者ID:J0WI,项目名称:mozillians,代码行数:7,代码来源:test_models.py


示例5: test_extract_document

    def test_extract_document(self):
        user = UserFactory.create(userprofile={'allows_community_sites': False,
                                               'allows_mozilla_sites': False,
                                               'full_name': 'Nikos Koukos',
                                               'bio': 'This is my bio'})
        profile = user.userprofile
        group_1 = GroupFactory.create()
        group_2 = GroupFactory.create()
        skill_1 = SkillFactory.create()
        skill_2 = SkillFactory.create()
        LanguageFactory.create(code='fr', userprofile=profile)
        LanguageFactory.create(code='en', userprofile=profile)
        group_1.add_member(profile)
        group_2.add_member(profile)
        profile.skills.add(skill_1)
        profile.skills.add(skill_2)

        result = UserProfileMappingType.extract_document(profile.id)
        ok_(isinstance(result, dict))
        eq_(result['id'], profile.id)
        eq_(result['is_vouched'], profile.is_vouched)
        eq_(result['region'], 'attika')
        eq_(result['city'], 'athens')
        eq_(result['allows_community_sites'], profile.allows_community_sites)
        eq_(result['allows_mozilla_sites'], profile.allows_mozilla_sites)
        eq_(set(result['country']), set(['gr', 'greece']))
        eq_(result['fullname'], profile.full_name.lower())
        eq_(result['name'], profile.full_name.lower())
        eq_(result['bio'], profile.bio)
        eq_(result['has_photo'], False)
        eq_(result['groups'], [group_1.name, group_2.name])
        eq_(result['skills'], [skill_1.name, skill_2.name])
        eq_(set(result['languages']),
            set([u'en', u'fr', u'english', u'french', u'français']))
开发者ID:royshouvik,项目名称:mozillians,代码行数:34,代码来源:test_models.py


示例6: test_cis_groups_highest

    def test_cis_groups_highest(self):
        user = UserFactory.create()
        group1 = GroupFactory.create(name='nda',
                                     is_access_group=True)
        group2 = GroupFactory.create(name='cis_whitelist',
                                     is_access_group=True)
        group3 = GroupFactory.create(name='open innovation + reps council',
                                     is_access_group=True)
        group4 = GroupFactory.create(name='group4')
        group1.add_member(user.userprofile)
        group2.add_member(user.userprofile)
        group3.add_member(user.userprofile)
        group4.add_member(user.userprofile, status='PENDING')
        IdpProfile.objects.create(
            profile=user.userprofile,
            auth0_user_id='github|[email protected]',
            primary=False,
            email='[email protected]'
        )
        idp = IdpProfile.objects.create(
            profile=user.userprofile,
            auth0_user_id='ad|[email protected]',
            primary=True,
            email='[email protected]'
        )

        eq_(set(user.userprofile.get_cis_groups(idp)),
            set(['mozilliansorg_nda', 'mozilliansorg_cis_whitelist',
                 'mozilliansorg_open-innovation-reps-council']))
开发者ID:johngian,项目名称:mozillians,代码行数:29,代码来源:test_models.py


示例7: test_export_view_post

    def test_export_view_post(self):
        user = UserFactory.create(is_superuser=True, is_staff=True)
        export_url = reverse('admin:users_userprofile_export')

        # NDA group required for admin response rendering
        GroupFactory.create(name=settings.NDA_GROUP)

        mock_bucket = MagicMock()
        mock_connection = MagicMock()
        mock_connection.get_bucket.return_value = mock_bucket

        with patch('mozillians.common.mixins.S3ExportMixin.get_export_filename') as mock_filename:
            with patch('mozillians.common.mixins.boto') as mock_boto:
                mock_boto.connect_s3.return_value = mock_connection
                mock_filename.return_value = 'example_filename.format'

                with self.login(user) as client:
                    data = {
                        'file_format': '0'
                    }

                    client.post(export_url, data=data)

                kwargs = {
                    'calling_format': ANY,
                    'aws_access_key_id': 'foo',
                    'aws_secret_access_key': 'bar'
                }
                calling_format = mock_boto.connect_s3.call_args[1]['calling_format']

                mock_boto.connect_s3.assert_called_with(**kwargs)
                ok_(isinstance(calling_format, boto.s3.connection.OrdinaryCallingFormat))
                mock_connection.get_bucket.assert_called_with('s3-bucket')
                mock_bucket.new_key.assert_called_with('example_filename.format')
开发者ID:akatsoulas,项目名称:mozillians,代码行数:34,代码来源:test_mixins.py


示例8: test_update_basket_task

    def test_update_basket_task(self, mock_basket):
        # When a user is created or added to a group, the appropriate
        # calls to update basket are made
        email = '[email protected]'
        token = 'footoken'
        mock_basket.lookup_user.return_value = {
            'email': email,
        }
        mock_basket.subscribe.return_value = {
            'token': token,
        }
        user = UserFactory.create(email=email)
        mock_basket.subscribe.reset_mock()  # forget that subscribe was called
        group = GroupFactory.create(name='Web Development',
                                    functional_area=True)
        GroupFactory.create(name='Marketing', functional_area=True)
        data = {'country': 'gr',
                'city': 'Athens',
                'WEB_DEVELOPMENT': 'Y',
                'MARKETING': 'N'}

        group.add_member(user.userprofile)

        # We just added a group, we should not need to subscribe anything
        ok_(not mock_basket.subscribe.called)
        # But we do need to update their phonebook record
        mock_basket.request.assert_called_with(
            'post', 'custom_update_phonebook', token=token, data=data)
开发者ID:KryDos,项目名称:mozillians,代码行数:28,代码来源:test_tasks.py


示例9: test_valid_name

 def test_valid_name(self):
     """Valid group with name that matches the old group regex doens't redirect."""
     group = GroupFactory.create(name='111-foo')
     GroupFactory.create(name='foo')
     url = reverse('groups:show', kwargs={'url': group.url})
     with self.login(self.user) as client:
         response = client.get(url, follow=True)
     eq_(response.status_code, 200)
     eq_(response.context['group'], group)
开发者ID:SudeepSrinivas,项目名称:mozillians,代码行数:9,代码来源:test_middleware.py


示例10: test_member_counts

    def test_member_counts(self):
        group = GroupFactory()
        user = UserFactory.create()
        group.add_member(user.userprofile)
        admin = GroupAdmin(model=Group, admin_site=site)
        mock_request = Mock(spec=HttpRequest)
        qset = admin.queryset(mock_request)

        g = qset.get(name=group.name)
        eq_(1, g.member_count)
开发者ID:CDees,项目名称:mozillians,代码行数:10,代码来源:test_admin.py


示例11: setUp

 def setUp(self):
     self.user = UserFactory.create()
     self.group_1 = GroupFactory.create(name='abc')
     self.group_2 = GroupFactory.create(name='def')
     self.group_2.add_member(self.user.userprofile)
     self.query = Group.objects.filter(pk__in=[self.group_1.pk, self.group_2.pk])
     self.template = 'groups/index.html'
     self.request = RequestFactory()
     self.request.GET = {}
     self.request.user = self.user
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:10,代码来源:test_list.py


示例12: test_autocomplete_assign

 def test_autocomplete_assign(self):
     user = UserFactory.create()
     group_1 = GroupFactory.create()
     group_2 = GroupFactory.create(auto_complete=False)
     group_1.members.add(user.userprofile)
     tasks.assign_autocomplete_to_groups()
     group_1 = Group.objects.get(pk=group_1.pk)
     group_2 = Group.objects.get(pk=group_2.pk)
     eq_(group_1.auto_complete, True)
     eq_(group_2.auto_complete, False)
开发者ID:Narrator,项目名称:mozillians,代码行数:10,代码来源:test_tasks.py


示例13: test_merge_groups

 def test_merge_groups(self):
     master_group = GroupFactory.create()
     merge_group_1 = GroupFactory.create()
     merge_group_2 = GroupFactory.create()
     nested_group = GroupFactory.create()
     merge_group_1.merge_groups([nested_group])
     master_group.merge_groups([merge_group_1, merge_group_2])
     eq_(master_group.aliases.count(), 4)
     for group in [merge_group_1, merge_group_2, nested_group]:
         ok_(master_group.aliases.filter(name=group.name, url=group.url).exists())
         ok_(not Group.objects.filter(pk=group.pk).exists())
开发者ID:rahulrrixe,项目名称:mozillians,代码行数:11,代码来源:test_models.py


示例14: test_distinct_results

 def test_distinct_results(self):
     user = UserFactory.create()
     group_1 = GroupFactory.create()
     group_2 = GroupFactory.create()
     group_1.add_member(user.userprofile)
     group_2.add_member(user.userprofile)
     client = Client()
     url = urlparams(self.mozilla_resource_url, groups=",".join([group_1.name, group_2.name]))
     response = client.get(url, follow=True)
     data = json.loads(response.content)
     eq_(response.status_code, 200)
     eq_(len(data["objects"]), 1)
开发者ID:jensonk9,项目名称:mozillians,代码行数:12,代码来源:test_api.py


示例15: setUp

 def setUp(self):
     self.user = UserFactory.create(userprofile={'is_vouched': True})
     self.group_1 = GroupFactory.create()
     self.group_2 = GroupFactory.create()
     self.group_2.members.add(self.user.userprofile)
     self.query = (Group.objects
                   .filter(pk__in=[self.group_1.pk, self.group_2.pk])
                   .annotate(num_members=Count('members')))
     self.template = 'groups/index.html'
     self.request = RequestFactory()
     self.request.GET = {}
     self.request.user = self.user
开发者ID:NightFury13,项目名称:mozillians,代码行数:12,代码来源:test_views.py


示例16: test_get_annotated_groups_only_visible

    def test_get_annotated_groups_only_visible(self):
        """ Test that get_annotated_groups() only returns visible groups

        """
        group_1 = GroupFactory.create(visible=True)
        group_2 = GroupFactory.create(visible=False)
        profile = UserFactory.create().userprofile
        group_1.add_member(profile)
        group_2.add_member(profile)

        user_groups = profile.get_annotated_groups()
        eq_([group_1], user_groups)
开发者ID:royshouvik,项目名称:mozillians,代码行数:12,代码来源:test_models.py


示例17: test_index_functional_areas

    def test_index_functional_areas(self):
        user = UserFactory.create(userprofile={"is_vouched": True})
        group_1 = GroupFactory.create(steward=user.userprofile)
        group_2 = GroupFactory.create()
        GroupFactory.create()
        group_1.members.add(user.userprofile)
        group_2.members.add(user.userprofile)

        with self.login(user) as client:
            response = client.get(self.url, follow=True)
        eq_(response.status_code, 200)
        self.assertTemplateUsed(response, "groups/index_areas.html")
        eq_(set(response.context["groups"].paginator.object_list), set([group_1]))
开发者ID:Narrator,项目名称:mozillians,代码行数:13,代码来源:test_views.py


示例18: test_search_existing_group

    def test_search_existing_group(self):
        user = UserFactory.create()
        group_1 = GroupFactory.create(visible=True)
        GroupFactory.create()
        url = urlparams(reverse("groups:search_groups"), term=group_1.name)
        with self.login(user) as client:
            response = client.get(url, follow=True, **{"HTTP_X_REQUESTED_WITH": "XMLHttpRequest"})
        eq_(response.status_code, 200)
        eq_(response.get("content-type"), "application/json")

        data = json.loads(response.content)
        eq_(len(data), 1, "Non autocomplete groups are included in search")
        eq_(data[0], group_1.name)
开发者ID:ariestiyansyah,项目名称:mozillians,代码行数:13,代码来源:test_search.py


示例19: test_search_groups

    def test_search_groups(self):
        client = Client()
        group_1 = GroupFactory.create()
        group_2 = GroupFactory.create()
        user_1 = UserFactory.create()
        group_1.add_member(user_1.userprofile)
        user_2 = UserFactory.create()
        group_2.add_member(user_2.userprofile)

        url = urlparams(self.mozilla_resource_url, groups=group_1.name)
        response = client.get(url, follow=True)
        data = json.loads(response.content)
        eq_(len(data["objects"]), 1)
        eq_(data["objects"][0]["id"], user_1.userprofile.id)
开发者ID:jensonk9,项目名称:mozillians,代码行数:14,代码来源:test_api.py


示例20: test_search_groups

    def test_search_groups(self):
        client = Client()
        group_1 = GroupFactory.create()
        group_2 = GroupFactory.create()
        user_1 = UserFactory.create(userprofile={'is_vouched': True})
        user_1.userprofile.groups.add(group_1)
        user_2 = UserFactory.create(userprofile={'is_vouched': True})
        user_2.userprofile.groups.add(group_2)

        url = urlparams(self.mozilla_resource_url, groups=group_1.name)
        response = client.get(url, follow=True)
        data = json.loads(response.content)
        eq_(len(data['objects']), 1)
        eq_(data['objects'][0]['id'], unicode(user_1.userprofile.id))
开发者ID:TheGallery,项目名称:mozillians,代码行数:14,代码来源:test_api.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tests.SkillFactory类代码示例发布时间:2022-05-27
下一篇:
Python tests.GroupAliasFactory类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap