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


Python GroupFactory.create方法代码示例

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


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

示例1: test_update_basket_task

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
    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,代码行数:30,代码来源:test_tasks.py

示例2: test_set_membership_group_matches_alias

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
 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,代码行数:9,代码来源:test_models.py

示例3: test_extract_document

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
    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,代码行数:36,代码来源:test_models.py

示例4: test_export_view_post

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
    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,代码行数:36,代码来源:test_mixins.py

示例5: test_update_basket_task_without_token

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
    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,代码行数:27,代码来源:test_tasks.py

示例6: test_cis_groups_highest

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
    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,代码行数:31,代码来源:test_models.py

示例7: test_valid_name

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
 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,代码行数:11,代码来源:test_middleware.py

示例8: setUp

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
 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,代码行数:12,代码来源:test_list.py

示例9: test_autocomplete_assign

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
 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,代码行数:12,代码来源:test_tasks.py

示例10: test_merge_groups

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
 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,代码行数:13,代码来源:test_models.py

示例11: setUp

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
 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,代码行数:14,代码来源:test_views.py

示例12: test_distinct_results

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
 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,代码行数:14,代码来源:test_api.py

示例13: test_get_annotated_groups_only_visible

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
    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,代码行数:14,代码来源:test_models.py

示例14: test_search_existing_group

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
    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,代码行数:15,代码来源:test_search.py

示例15: test_index_functional_areas

# 需要导入模块: from mozillians.groups.tests import GroupFactory [as 别名]
# 或者: from mozillians.groups.tests.GroupFactory import create [as 别名]
    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,代码行数:15,代码来源:test_views.py


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