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


Python tests.NGReportCommentFactory类代码示例

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


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

示例1: 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

示例2: test_one_user_settings_False

 def test_one_user_settings_False(self, mocked_mail):
     """Test sending email when a new comment is added on a NGReport
     and the user has the option disabled in his/her settings.
     """
     comment_user = UserFactory.create()
     user = UserFactory.create(
         userprofile__receive_email_on_add_comment=False)
     report = NGReportFactory.create(user=user)
     NGReportCommentFactory.create(user=comment_user, report=report,
                                   comment='This is a comment')
     ok_(not mocked_mail.called)
开发者ID:Josespaul,项目名称:remo,代码行数:11,代码来源:test_models.py

示例3: test_send_email_on_report_comment_settings_False_one_user

    def test_send_email_on_report_comment_settings_False_one_user(self):
        """Test sending email when a new comment is added on a NGReport

        and the user has the option disabled in his/her settings.
        """
        comment_user = UserFactory.create()
        user = UserFactory.create(
            userprofile__receive_email_on_add_comment=False)
        report = NGReportFactory.create(user=user)
        NGReportCommentFactory.create(user=comment_user, report=report,
                                      comment='This is a comment')

        eq_(len(mail.outbox), 0)
开发者ID:hoosteeno,项目名称:remo,代码行数:13,代码来源:test_models.py

示例4: test_comment_one_user

    def test_comment_one_user(self, mocked_mail):
        """Test sending email when a new comment is added on a NGReport
        and the user has the option enabled in his/her settings.
        """
        commenter = UserFactory.create()
        reporter = UserFactory.create(userprofile__receive_email_on_add_comment=True)
        report = NGReportFactory.create(user=reporter)
        NGReportCommentFactory.create(user=commenter, report=report, comment='This is a comment')

        ok_(mocked_mail.called)
        eq_(mocked_mail.call_count, 1)
        mocked_data = mocked_mail.call_args_list[0][1]
        msg = '[Report] User {0} commented on {1}'.format(commenter.get_full_name(), report)
        eq_(mocked_data['subject'], msg)
开发者ID:Josespaul,项目名称:remo,代码行数:14,代码来源:test_models.py

示例5: test_as_admin

 def test_as_admin(self, redirect_mock):
     user = UserFactory.create(groups=['Admin'])
     report = NGReportFactory.create()
     report_comment = NGReportCommentFactory.create(report=report)
     self.post(user=user, url=report_comment.get_absolute_delete_url())
     ok_(not NGReportComment.objects.filter(pk=report_comment.id).exists())
     redirect_mock.assert_called_with(report.get_absolute_url())
开发者ID:hoosteeno,项目名称:remo,代码行数:7,代码来源:test_views.py

示例6: test_comment_one_user

    def test_comment_one_user(self):
        """Test sending email when a new comment is added on a NGReport
        and the user has the option enabled in his/her settings.
        """
        commenter = UserFactory.create()
        reporter = UserFactory.create(
            userprofile__receive_email_on_add_comment=True)
        report = NGReportFactory.create(user=reporter)
        NGReportCommentFactory.create(user=commenter, report=report,
                                      comment='This is a comment')

        eq_(len(mail.outbox), 1)
        eq_(reporter.email, mail.outbox[0].to[0])
        msg = ('[Report] User {0} commented on {1}'
               .format(commenter.get_full_name(), report))
        eq_(mail.outbox[0].subject, msg)
开发者ID:SamBlake1,项目名称:remo,代码行数:16,代码来源:test_models.py

示例7: test_get_absolute_delete_url

 def test_get_absolute_delete_url(self):
     report = NGReportFactory.create(
         report_date=datetime.date(2012, 01, 01), id=9999)
     report_comment = NGReportCommentFactory.create(report=report,
                                                    user=report.user)
     eq_(report_comment.get_absolute_delete_url(),
         ('/u/%s/r/2012/January/1/9999/comment/%s/delete/'
          % (report.user.userprofile.display_name, report_comment.id)))
开发者ID:josephbosire,项目名称:remo,代码行数:8,代码来源:test_models.py

示例8: test_comment_multiple_users

    def test_comment_multiple_users(self, mocked_mail):
        """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
        with mute_signals(post_save):
            for user_obj in users_with_comments:
                NGReportCommentFactory.create(user=user_obj, report=report,
                                              comment='This is a comment')
        NGReportCommentFactory.create(user=commenter, report=report,
                                      comment='This is a comment')

        ok_(mocked_mail.called)
        eq_(mocked_mail.call_count, 3)
        msg = '[Report] User {0} commented on {1}'.format(commenter.get_full_name(), report)
        mocked_data = mocked_mail.call_args_list[0][1]
        eq_(mocked_data['subject'], msg)
开发者ID:Josespaul,项目名称:remo,代码行数:22,代码来源:test_models.py

示例9: test_get

 def test_get(self):
     report = NGReportFactory.create()
     report_comment = NGReportCommentFactory.create(report=report)
     self.get(user=report.user,
              url=report_comment.get_absolute_delete_url())
     ok_(NGReportComment.objects.filter(pk=report_comment.id).exists())
开发者ID:hoosteeno,项目名称:remo,代码行数:6,代码来源:test_views.py

示例10: test_as_other_rep

 def test_as_other_rep(self):
     user = UserFactory.create()
     report = NGReportFactory.create()
     report_comment = NGReportCommentFactory.create(report=report)
     self.post(user=user, url=report_comment.get_absolute_delete_url())
     ok_(NGReportComment.objects.filter(pk=report_comment.id).exists())
开发者ID:hoosteeno,项目名称:remo,代码行数:6,代码来源:test_views.py


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