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


Python UserFactory.create_batch方法代码示例

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


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

示例1: test_filter_emails_alternate

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
 def test_filter_emails_alternate(self):
     request = self.factory.get('/', {'email': '[email protected]'})
     user = UserFactory.create(email='[email protected]')
     UserFactory.create_batch(2)
     ExternalAccount.objects.create(user=user.userprofile, type=ExternalAccount.TYPE_EMAIL,
                                    identifier='[email protected]')
     f = UserProfileFilter(request.GET, queryset=UserProfile.objects.all())
     eq_(f.qs.count(), 1)
     eq_(f.qs[0], user.userprofile)
开发者ID:fxa90id,项目名称:mozillians,代码行数:11,代码来源:test_api_v2.py

示例2: test_filter_emails_alternate_idp

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
 def test_filter_emails_alternate_idp(self):
     request = self.factory.get('/', {'email': '[email protected]'})
     user = UserFactory.create(email='[email protected]')
     UserFactory.create_batch(2)
     IdpProfile.objects.create(
         profile=user.userprofile,
         auth0_user_id='ad|[email protected]',
         email='[email protected]'
     )
     f = UserProfileFilter(request.GET, queryset=UserProfile.objects.all())
     eq_(f.qs.count(), 1)
     eq_(f.qs[0], user.userprofile)
开发者ID:akatsoulas,项目名称:mozillians,代码行数:14,代码来源:test_api_v2.py

示例3: test_group_member_count_only_members

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
    def test_group_member_count_only_members(self):
        group = GroupFactory.create(name='foo')
        users = UserFactory.create_batch(3)
        for u in users:
            group.add_member(u.userprofile)

        eq_(Group.objects.get(name='foo').member_count, 3)
开发者ID:akatsoulas,项目名称:mozillians,代码行数:9,代码来源:test_models.py

示例4: test_skill_member_count

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
    def test_skill_member_count(self):
        skill = SkillFactory.create(name='foo')
        users = UserFactory.create_batch(3)
        for u in users:
            skill.add_member(u.userprofile)

        eq_(Skill.objects.get(name='foo').member_count, 3)
开发者ID:akatsoulas,项目名称:mozillians,代码行数:9,代码来源:test_models.py

示例5: test_accept_reject_user_not_redeemer

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
    def test_accept_reject_user_not_redeemer(self):
        inviter, redeemer = UserFactory.create_batch(2)
        invite = InviteFactory.create(inviter=inviter.userprofile, redeemer=redeemer.userprofile)
        user = UserFactory.create()

        with self.login(user) as client:
            url = reverse("groups:accept_reject_invitation", args=[invite.pk, "accept"])
            response = client.get(url, follow=True)
            eq_(response.status_code, 404)
开发者ID:johngian,项目名称:mozillians,代码行数:11,代码来源:test_invite.py

示例6: test_send_invitation_email_no_curator_manager

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
    def test_send_invitation_email_no_curator_manager(self):
        inviter, redeemer = UserFactory.create_batch(2)
        invite = InviteFactory.create(inviter=inviter.userprofile, redeemer=redeemer.userprofile)
        user = UserFactory.create()

        with self.login(user) as client:
            url = urlparams(reverse("groups:send_invitation_email", args=[invite.pk]), "invitation")
            response = client.get(url, follow=True)
            eq_(response.status_code, 404)
开发者ID:johngian,项目名称:mozillians,代码行数:11,代码来源:test_invite.py

示例7: test_reject_invitation

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
    def test_reject_invitation(self):
        inviter, redeemer = UserFactory.create_batch(2)
        invite = InviteFactory.create(inviter=inviter.userprofile, redeemer=redeemer.userprofile)

        with self.login(redeemer) as client:
            url = reverse("groups:accept_reject_invitation", args=[invite.pk, "reject"])
            response = client.get(url, follow=True)
            eq_(response.status_code, 200)

        invite = Invite.objects.filter(pk=invite.pk)
        ok_(not invite.exists())
开发者ID:johngian,项目名称:mozillians,代码行数:13,代码来源:test_invite.py

示例8: test_accept_invitation_without_terms

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
    def test_accept_invitation_without_terms(self):
        inviter, redeemer = UserFactory.create_batch(2)
        invite = InviteFactory.create(inviter=inviter.userprofile, redeemer=redeemer.userprofile)

        with self.login(redeemer) as client:
            url = reverse("groups:accept_reject_invitation", args=[invite.pk, "accept"])
            response = client.get(url, follow=True)
            eq_(response.status_code, 200)

        invite = Invite.objects.get(pk=invite.pk)
        ok_(invite.accepted)
        ok_(invite.group.has_member(redeemer.userprofile))
开发者ID:johngian,项目名称:mozillians,代码行数:14,代码来源:test_invite.py

示例9: test_group_member_count_non_members

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
    def test_group_member_count_non_members(self):
        group = GroupFactory.create(name='foo')
        users = UserFactory.create_batch(10)

        for u in users[:3]:
            group.add_member(u.userprofile, status=GroupMembership.MEMBER)

        for u in users[3:7]:
            group.add_member(u.userprofile, status=GroupMembership.PENDING)

        for u in users[7:]:
            group.add_member(u.userprofile, status=GroupMembership.PENDING_TERMS)

        eq_(Group.objects.get(name='foo').member_count, 3)
开发者ID:akatsoulas,项目名称:mozillians,代码行数:16,代码来源:test_models.py

示例10: test_send_invitation_email_different_curator

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
    def test_send_invitation_email_different_curator(self, mock_success, mock_notification):
        curator, inviter = UserFactory.create_batch(2)
        redeemer = UserFactory.create(userprofile={"full_name": "Foo Bar"})
        invite = InviteFactory.create(inviter=inviter.userprofile, redeemer=redeemer.userprofile)
        invite.group.curators.add(curator.userprofile)
        invite.group.curators.add(inviter.userprofile)

        with self.login(curator) as client:
            url = urlparams(reverse("groups:send_invitation_email", args=[invite.pk]), "invitation")
            response = client.get(url, follow=True)
            eq_(response.status_code, 200)

        mock_notification.delay.assert_called_once_with(invite.pk, "")
        msg = "Invitation to Foo Bar has been sent successfully."
        mock_success.assert_called_once_with(ANY, msg)
开发者ID:johngian,项目名称:mozillians,代码行数:17,代码来源:test_invite.py

示例11: test_send_invitation_invalid_email

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
 def test_send_invitation_invalid_email(self, mock_send_email):
     inviter, redeemer = UserFactory.create_batch(2)
     group = GroupFactory.create(name='Foo')
     template_name = 'groups/email/invite_invalid_email.txt'
     InviteFactory.create(inviter=inviter.userprofile,
                          redeemer=redeemer.userprofile,
                          group=group)
     with patch('mozillians.groups.tasks.get_template', autospec=True) as mock_get_template:
         tasks.notify_redeemer_invitation_invalid(redeemer.userprofile.pk, group.pk)
     args = [
         '[Mozillians] Invitation to group "foo" is no longer valid',
         ANY,
         '[email protected]',
         [redeemer.userprofile.email]
     ]
     ok_(mock_get_template.called)
     eq_(template_name, mock_get_template.call_args[0][0])
     mock_send_email.assert_called_once_with(*args)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:20,代码来源:test_tasks.py

示例12: test_accept_invitation_with_terms

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
    def test_accept_invitation_with_terms(self):
        inviter, redeemer = UserFactory.create_batch(2)
        invite = InviteFactory.create(inviter=inviter.userprofile, redeemer=redeemer.userprofile)
        invite.group.terms = "Group Terms"
        invite.group.save()

        with self.login(redeemer) as client:
            url = reverse("groups:accept_reject_invitation", args=[invite.pk, "accept"])
            response = client.get(url, follow=True)
            eq_(response.status_code, 200)

        invite = Invite.objects.get(pk=invite.pk)
        ok_(invite.accepted)
        ok_(
            invite.group.groupmembership_set.filter(
                userprofile=redeemer.userprofile, status=GroupMembership.PENDING_TERMS
            ).exists()
        )
开发者ID:johngian,项目名称:mozillians,代码行数:20,代码来源:test_invite.py

示例13: test_show_common_skills

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
    def test_show_common_skills(self):
        """Show most common skills first."""
        user_1 = UserFactory.create()
        user_2 = UserFactory.create()
        user_3 = UserFactory.create()
        user_4 = UserFactory.create()

        group = GroupFactory.create()
        group.add_member(user_1.userprofile)
        group.add_member(user_2.userprofile)
        group.add_member(user_3.userprofile)
        group.add_member(user_4.userprofile)

        skill_1 = SkillFactory.create()
        skill_2 = SkillFactory.create()
        skill_3 = SkillFactory.create()
        skill_4 = SkillFactory.create()
        skill_3.members.add(user_1.userprofile)
        skill_3.members.add(user_2.userprofile)
        skill_3.members.add(user_3.userprofile)
        skill_3.members.add(user_4.userprofile)
        skill_2.members.add(user_2.userprofile)
        skill_2.members.add(user_3.userprofile)
        skill_2.members.add(user_4.userprofile)
        skill_4.members.add(user_3.userprofile)
        skill_4.members.add(user_4.userprofile)
        skill_1.members.add(user_1.userprofile)
        users = UserFactory.create_batch(5)
        for user in users:
            skill_4.members.add(user.userprofile)

        url = reverse('groups:show_group', kwargs={'url': group.url})
        with self.login(user_1) as client:
            response = client.get(url, follow=True)
        eq_(response.status_code, 200)
        skills = response.context['skills']
        eq_(skills[0], skill_3)
        eq_(skills[1], skill_2)
        eq_(skills[2], skill_4)
        ok_(skill_1 not in skills)
开发者ID:Acidburn0zzz,项目名称:mozillians,代码行数:42,代码来源:test_show.py

示例14: test_only_unvouched

# 需要导入模块: from mozillians.users.tests import UserFactory [as 别名]
# 或者: from mozillians.users.tests.UserFactory import create_batch [as 别名]
 def test_only_unvouched(self):
     UserFactory.create_batch(4, vouched=False)
     UserFactory.create_batch(3, vouched=True)
     qs = UserProfile.objects.all()
     eq_(filter_vouched(qs, 'no').count(), 4)
开发者ID:akatsoulas,项目名称:mozillians,代码行数:7,代码来源:test_forms.py


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