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

Python tests.UserFactory类代码示例

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

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



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

示例1: test_update_valid_groups

    def test_update_valid_groups(self):
        model = ContentType.objects.get_for_model(Poll)
        items = ActionItem.objects.filter(content_type=model)
        ok_(not items.exists())

        council = Group.objects.get(name='Council')
        reps = Group.objects.get(name='Rep')
        UserFactory.create_batch(3, groups=['Council'])
        UserFactory.create_batch(4, groups=['Rep'])
        start = now() - timedelta(hours=3)
        poll = PollFactory.create(valid_groups=council, start=start)

        create_poll_action_items()

        poll.valid_groups = reps
        poll.save()

        items = ActionItem.objects.filter(content_type=model,
                                          object_id=poll.id)
        eq_(items.count(), 4)

        for user in reps.user_set.all():
            ok_(items.filter(user=user).exists())

        for user in council.user_set.all():
            ok_(not items.filter(user=user).exists())
开发者ID:abshetewy,项目名称:remo,代码行数:26,代码来源:test_models.py


示例2: test_send_mail

    def test_send_mail(self, fake_messages):
        """Test EmailRepsForm email sending functionality."""

        data = {'subject': 'Test email subject',
                'body': 'Test email body',
                'functional_area': self.functional_area.id}

        form = EmailRepsForm(data=data)
        ok_(form.is_valid())

        area = self.functional_area
        UserFactory.create_batch(20, userprofile__functional_areas=[area])

        factory = RequestFactory()
        request = factory.request()
        request.user = UserFactory.create()

        reps = User.objects.filter(userprofile__functional_areas__name=area)

        form.send_email(request, reps)

        eq_(len(mail.outbox), 20)

        def format_name(user):
            return '%s %s <%s>' % (user.first_name, user.last_name, user.email)
        recipients = map(format_name, reps)

        receivers = []
        for i in range(0, len(mail.outbox)):
            eq_(mail.outbox[i].subject, data['subject'])
            eq_(mail.outbox[i].body, data['body'])
            receivers.append(mail.outbox[i].to[0])

        eq_(set(receivers), set(recipients))
        fake_messages.assert_called_with(ANY, 'Email sent successfully.')
开发者ID:Azeez09,项目名称:remo,代码行数:35,代码来源:test_forms.py


示例3: test_send_mail

    def test_send_mail(self, fake_messages):
        """Test EmailRepsForm email sending functionality."""

        data = {"subject": "Test email subject", "body": "Test email body", "functional_area": self.functional_area.id}

        form = EmailRepsForm(data=data)
        ok_(form.is_valid())

        area = self.functional_area
        UserFactory.create_batch(20, userprofile__functional_areas=[area])

        factory = RequestFactory()
        request = factory.request()
        request.user = UserFactory.create()

        reps = User.objects.filter(userprofile__functional_areas__name=area)

        form.send_email(request, reps)

        eq_(len(mail.outbox), 20)

        address = lambda u: "%s %s <%s>" % (u.first_name, u.last_name, u.email)
        recipients = map(address, reps)

        receivers = []
        for i in range(0, len(mail.outbox)):
            eq_(mail.outbox[i].subject, data["subject"])
            eq_(mail.outbox[i].body, data["body"])
            receivers.append(mail.outbox[i].to[0])

        eq_(set(receivers), set(recipients))
        fake_messages.assert_called_with(ANY, "Email sent successfully.")
开发者ID:ppapadeas,项目名称:remo,代码行数:32,代码来源:test_forms.py


示例4: test_view_dashboard_page

    def test_view_dashboard_page(self):
        """Get dashboard page."""
        c = Client()

        # Get as anonymous user.
        response = c.get(reverse('dashboard'), follow=True)
        eq_(response.status_code, 200)
        self.assertJinja2TemplateUsed(response, 'main.jinja')

        # Get as logged in rep.
        rep = UserFactory.create(groups=['Rep'])
        with self.login(rep) as client:
            response = client.get(reverse('dashboard'))
        eq_(response.status_code, 200)
        self.assertJinja2TemplateUsed(response, 'dashboard_reps.jinja')

        # Get as logged in mentor.
        mentor = UserFactory.create(groups=['Mentor'])
        with self.login(mentor) as client:
            response = client.get(reverse('dashboard'))
        eq_(response.status_code, 200)
        self.assertJinja2TemplateUsed(response, 'dashboard_reps.jinja')

        # Get as logged in counselor.
        councelor = UserFactory.create(groups=['Council'])
        with self.login(councelor) as client:
            response = client.get(reverse('dashboard'))
        eq_(response.status_code, 200)
        self.assertJinja2TemplateUsed(response, 'dashboard_reps.jinja')
开发者ID:Josespaul,项目名称:remo,代码行数:29,代码来源:test_views.py


示例5: test_dry_run

 def test_dry_run(self):
     """Test sending of first notification with debug activated."""
     mentor = UserFactory.create(groups=['Mentor'])
     rep = UserFactory.create(groups=['Rep'], userprofile__mentor=mentor)
     ReportFactoryWithoutSignals.create(user=rep)
     management.call_command('send_first_report_notification', dry_run=True)
     eq_(len(mail.outbox), 0)
开发者ID:prameet-jain,项目名称:remo,代码行数:7,代码来源:test_commands.py


示例6: test_resolve_mentor_validation

    def test_resolve_mentor_validation(self):
        model = ContentType.objects.get_for_model(Bug)
        items = ActionItem.objects.filter(content_type=model)
        ok_(not items.exists())

        mentor = UserFactory.create(groups=['Rep', 'Mentor'])
        UserFactory.create(groups=['Rep'], userprofile__mentor=mentor)

        bug = BugFactory.build(pending_mentor_validation=True,
                               assigned_to=mentor)
        bug.save()

        items = ActionItem.objects.filter(content_type=model)
        eq_(items.count(), 1)
        eq_(items[0].name, 'Waiting mentor validation for ' + bug.summary)
        eq_(items[0].user, mentor)
        eq_(items[0].priority, ActionItem.BLOCKER)

        bug.pending_mentor_validation = False
        bug.save()

        items = ActionItem.objects.filter(content_type=model, object_id=bug.id)
        for item in items:
            ok_(item.completed)
            ok_(item.resolved)
开发者ID:flaki,项目名称:remo,代码行数:25,代码来源:test_models.py


示例7: test_get_nominee_right_split

 def test_get_nominee_right_split(self):
     UserFactory.create(first_name='Foo', last_name='Foo Bar',
                        groups=['Rep'])
     user = get_nominee('Foo Foo Bar')
     ok_(user)
     eq_(user.first_name, 'Foo')
     eq_(user.last_name, 'Foo Bar')
开发者ID:Josespaul,项目名称:remo,代码行数:7,代码来源:test_helpers.py


示例8: test_comment_multiple_users

    def test_comment_multiple_users(self):
        """Test sending email when a new comment is added on a NGReport
        and the users have the option enabled in their settings.
        """
        commenter = UserFactory.create()
        reporter = UserFactory.create(
            userprofile__receive_email_on_add_comment=True)
        report = NGReportFactory.create(user=reporter)
        users_with_comments = UserFactory.create_batch(
            2, userprofile__receive_email_on_add_comment=True)
        # disconnect the signals in order to add two users in NGReportComment
        for user_obj in users_with_comments:
            NGReportCommentFactoryNoSignals.create(
                user=user_obj, report=report, comment='This is a comment')
        NGReportCommentFactory.create(user=commenter, report=report,
                                      comment='This is a comment')

        eq_(len(mail.outbox), 3)
        recipients = ['%s <%s>' % (reporter.get_full_name(), reporter.email),
                      '%s <%s>' % (users_with_comments[0].get_full_name(),
                                   users_with_comments[0].email),
                      '%s <%s>' % (users_with_comments[1].get_full_name(),
                                   users_with_comments[1].email)]
        receivers = [mail.outbox[0].to[0], mail.outbox[1].to[0],
                     mail.outbox[2].to[0]]
        eq_(set(recipients), set(receivers))
        msg = ('[Report] User {0} commented on {1}'
               .format(commenter.get_full_name(), report))
        eq_(mail.outbox[0].subject, msg)
开发者ID:Binzzzz,项目名称:remo,代码行数:29,代码来源:test_models.py


示例9: test_comment_multiple_users

    def test_comment_multiple_users(self):
        """Test sending email when a new comment is added on a Poll
        and the users have the option enabled in their settings.
        """
        commenter = UserFactory.create()
        creator = UserFactory.create(
            userprofile__receive_email_on_add_voting_comment=True)
        poll = PollFactoryNoSignals.create(created_by=creator)
        users_with_comments = UserFactory.create_batch(
            2, userprofile__receive_email_on_add_voting_comment=True)
        # disconnect the signals in order to add two users in PollComment
        for user_obj in users_with_comments:
            PollCommentFactoryNoSignals.create(
                user=user_obj, poll=poll, comment='This is a comment')
        PollCommentFactory.create(user=commenter, poll=poll,
                                  comment='This is a comment')

        eq_(len(mail.outbox), 3)
        recipients = ['%s <%s>' % (creator.get_full_name(), creator.email),
                      '%s <%s>' % (users_with_comments[0].get_full_name(),
                                   users_with_comments[0].email),
                      '%s <%s>' % (users_with_comments[1].get_full_name(),
                                   users_with_comments[1].email)]
        receivers = [mail.outbox[0].to[0], mail.outbox[1].to[0],
                     mail.outbox[2].to[0]]
        eq_(set(recipients), set(receivers))
        msg = ('[Voting] User {0} commented on {1}'
               .format(commenter.get_full_name(), poll))
        eq_(mail.outbox[0].subject, msg)
开发者ID:psvramaraju,项目名称:remo,代码行数:29,代码来源:test_models.py


示例10: test_send_notification

 def test_send_notification(self):
     """Test sending of first notification to Reps to fill reports."""
     mentor = UserFactory.create(groups=['Mentor'])
     rep = UserFactory.create(groups=['Rep'], userprofile__mentor=mentor)
     ReportFactoryWithoutSignals.create(user=rep)
     management.call_command('send_first_report_notification', [], {})
     eq_(len(mail.outbox), 1)
开发者ID:prameet-jain,项目名称:remo,代码行数:7,代码来源:test_commands.py


示例11: test_base

 def test_base(self):
     mentor = UserFactory.create()
     rep = UserFactory.create(userprofile__mentor=mentor)
     UserStatusFactory.create(user=rep, start_date=get_date(days=-1), is_unavailable=False)
     set_unavailability_flag()
     status = UserStatus.objects.get(user=rep)
     ok_(status.is_unavailable)
开发者ID:akatsoulas,项目名称:remo,代码行数:7,代码来源:test_tasks.py


示例12: test_list_no_alumni

 def test_list_no_alumni(self):
     """Test page header context for rep."""
     UserFactory.create(groups=['Rep'])
     response = self.get(reverse('profiles_alumni'))
     self.assertTemplateUsed(response, 'profiles_list_alumni.html')
     eq_(response.status_code, 200)
     ok_(not response.context['objects'].object_list)
开发者ID:Azeez09,项目名称:remo,代码行数:7,代码来源:test_views.py


示例13: test_base

 def test_base(self):
     mentor = UserFactory.create()
     user = UserFactory.create(userprofile__mentor=mentor)
     event = EventFactory.create()
     functional_areas = [FunctionalAreaFactory.create()]
     campaign = CampaignFactory.create()
     activity = ActivityFactory.create()
     report = NGReportFactory.create(
         functional_areas=functional_areas, mentor=mentor,
         campaign=campaign, user=user, event=event, activity=activity)
     url = '/api/beta/activities/%s' % report.id
     request = RequestFactory().get(url)
     data = ActivitiesDetailedSerializer(report,
                                         context={'request': request}).data
     eq_(data['user']['first_name'], user.first_name)
     eq_(data['user']['last_name'], user.last_name)
     eq_(data['user']['display_name'], user.userprofile.display_name)
     ok_(data['user']['_url'])
     eq_(data['activity'], activity.name)
     eq_(data['initiative'], campaign.name)
     eq_(data['functional_areas'][0]['name'], functional_areas[0].name)
     eq_(data['activity_description'], report.activity_description)
     eq_(data['location'], report.location)
     eq_(data['latitude'], float(report.latitude))
     eq_(data['longitude'], float(report.longitude))
     eq_(data['report_date'], report.report_date.strftime('%Y-%m-%d'))
     eq_(data['link'], report.link)
     eq_(data['link_description'], report.link_description)
     eq_(data['mentor']['first_name'], mentor.first_name)
     eq_(data['mentor']['last_name'], mentor.last_name)
     eq_(data['mentor']['display_name'], mentor.userprofile.display_name)
     ok_(data['mentor']['_url'])
     eq_(data['passive_report'], report.is_passive)
     eq_(data['event']['name'], event.name)
     ok_(data['event']['_url'])
开发者ID:Mte90,项目名称:remo,代码行数:35,代码来源:test_api.py


示例14: test_extend_voting_period_majority

    def test_extend_voting_period_majority(self):
        bug = BugFactory.create()
        start = now().replace(microsecond=0)
        end = datetime.combine(get_date(days=1), datetime.min.time())

        user = UserFactory.create(groups=['Admin'])
        group = Group.objects.get(name='Council')
        User.objects.filter(groups__name='Council').delete()
        UserFactory.create_batch(9, groups=['Council'])

        automated_poll = PollFactoryNoSignals.create(name='poll',
                                                     start=start, end=end,
                                                     valid_groups=group,
                                                     created_by=user,
                                                     automated_poll=True,
                                                     bug=bug)

        radio_poll = RadioPollFactory.create(poll=automated_poll,
                                             question='Budget Approval')
        RadioPollChoiceFactory.create(answer='Approved', votes=5,
                                      radio_poll=radio_poll)
        RadioPollChoiceFactory.create(answer='Denied', votes=3,
                                      radio_poll=radio_poll)

        extend_voting_period()

        poll = Poll.objects.get(pk=automated_poll.id)
        eq_(poll.end.year, end.year)
        eq_(poll.end.month, end.month)
        eq_(poll.end.day, end.day)
        eq_(poll.end.hour, 0)
        eq_(poll.end.minute, 0)
        eq_(poll.end.second, 0)
        ok_(not poll.is_extended)
开发者ID:Azeez09,项目名称:remo,代码行数:34,代码来源:test_tasks.py


示例15: test_send_mail

    def test_send_mail(self, fake_messages):
        """Test EmailRepsForm email sending functionality."""

        data = {'subject': 'Test email subject',
                'body': 'Test email body',
                'functional_area': self.functional_area.id}

        form = EmailRepsForm(data=data)
        ok_(form.is_valid())

        area = self.functional_area
        UserFactory.create_batch(20, userprofile__functional_areas=[area])

        factory = RequestFactory()
        request = factory.request()
        request.user = UserFactory.create()

        reps = User.objects.filter(userprofile__functional_areas__name=area)

        form.send_email(request, reps)

        eq_(len(mail.outbox), 1)

        address = lambda u: '%s %s <%s>' % (u.first_name, u.last_name, u.email)
        recipients = map(address, reps)

        eq_(set(mail.outbox[0].to), set(recipients))
        eq_(mail.outbox[0].subject, data['subject'])
        eq_(mail.outbox[0].body, data['body'])
        fake_messages.assert_called_with(ANY, 'Email sent successfully.')
开发者ID:ananthulasrikar,项目名称:remo,代码行数:30,代码来源:test_forms.py


示例16: setUp

    def setUp(self):
        """Setup tests."""
        self.admin = UserFactory.create(username='admin', groups=['Admin'])
        self.counselor = UserFactory.create(username='counselor')
        self.mentor = UserFactory.create(username='mentor', groups=['Mentor'])
        self.user = UserFactory.create(username='rep', groups=['Rep'],
                                       userprofile__mentor=self.mentor)
        self.up = self.user.userprofile

        self.data = {'empty': False,
                     'recruits': '10',
                     'recruits_comments': 'This is recruit comments.',
                     'past_items': 'This is past items.',
                     'next_items': 'This is next items.',
                     'flags': 'This is flags.',
                     'delete_report': False,
                     'reportevent_set-TOTAL_FORMS': '1',
                     'reportevent_set-INITIAL_FORMS': '0',
                     'reportevent_set-MAX_NUM_FORMS': '',
                     'reportevent_set-0-id': '',
                     'reportevent_set-0-name': 'Event name',
                     'reportevent_set-0-description': 'Event description',
                     'reportevent_set-0-link': 'http://example.com/evtlnk',
                     'reportevent_set-0-participation_type': '1',
                     'reportevent_set-0-DELETE': False,
                     'reportlink_set-TOTAL_FORMS': '1',
                     'reportlink_set-INITIAL_FORMS': '0',
                     'reportlink_set-MAX_NUM_FORMS': '',
                     'reportlink_set-0-id': '',
                     'reportlink_set-0-link': 'http://example.com/link',
                     'reportlink_set-0-description': 'This is description',
                     'reportlink_set-0-DELETE': False}
开发者ID:hoosteeno,项目名称:remo,代码行数:32,代码来源:test_views.py


示例17: test_get_as_other_rep

 def test_get_as_other_rep(self):
     user = UserFactory.create()
     rep = UserFactory.create()
     display_name = user.userprofile.display_name
     UserStatusFactory.create(user=user)
     url = reverse('edit_availability',
                   kwargs={'display_name': display_name})
     self.get(url=url, user=rep)
开发者ID:seocam,项目名称:remo,代码行数:8,代码来源:test_views.py


示例18: test_invalid_timespan

 def test_invalid_timespan(self):
     mentor = UserFactory.create()
     user = UserFactory.create(userprofile__mentor=mentor)
     date = get_date(weeks=15)
     data = {'expected_date': date}
     form = UserStatusForm(data, instance=UserStatus(user=user))
     ok_(not form.is_valid())
     ok_('expected_date' in form.errors)
开发者ID:abshetewy,项目名称:remo,代码行数:8,代码来源:test_forms.py


示例19: test_automated_radio_poll_valid_bug

 def test_automated_radio_poll_valid_bug(self):
     """Test the creation of an automated radio poll."""
     UserFactory.create(username='remobot')
     bug = BugFactory.create(council_vote_requested=True, component='Budget Requests')
     poll = Poll.objects.get(bug=bug)
     eq_(poll.bug.bug_id, bug.bug_id)
     eq_(poll.description, bug.first_comment)
     eq_(poll.name, bug.summary)
开发者ID:Josespaul,项目名称:remo,代码行数:8,代码来源:test_models.py


示例20: test_get_as_anonymous

 def test_get_as_anonymous(self):
     mentor = UserFactory.create()
     user = UserFactory.create(userprofile__mentor=mentor)
     display_name = user.userprofile.display_name
     UserStatusFactory.create(user=user)
     client = Client()
     client.get(reverse('edit_availability',
                        kwargs={'display_name': display_name}))
开发者ID:abshetewy,项目名称:remo,代码行数:8,代码来源:test_views.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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