當前位置: 首頁>>代碼示例>>Python>>正文


Python tests.ReportFactory類代碼示例

本文整理匯總了Python中remo.reports.tests.ReportFactory的典型用法代碼示例。如果您正苦於以下問題:Python ReportFactory類的具體用法?Python ReportFactory怎麽用?Python ReportFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ReportFactory類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_post_comment_on_report

    def test_post_comment_on_report(self):
        """Test post comment on report."""
        # Test with anonymous user.
        c = Client()
        ReportFactory.create(user=self.user, empty=True, mentor=self.mentor,
                             month=datetime.date(2012, 1, 1))
        report_view_url = reverse('reports_view_report',
                                  kwargs={'display_name': self.up.display_name,
                                          'year': '2012',
                                          'month': 'January'})
        response = c.post(report_view_url, {'comment': 'This is comment'},
                          follow=True)
        self.assertTemplateUsed(response, 'main.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'error')

        # Test with logged in user.
        c.login(username='mentor', password='passwd')
        response = c.post(report_view_url, {'comment': 'This is comment'},
                          follow=True)
        self.assertTemplateUsed(response, 'view_report.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'success')
        self.assertIn('This is comment', response.content)
開發者ID:hoosteeno,項目名稱:remo,代碼行數:26,代碼來源:test_views.py

示例2: test_send_email_on_edit_report_with_receive_mail_True

    def test_send_email_on_edit_report_with_receive_mail_True(self):
        """Test sending an email when a report is edited

           and Mentor has the option in his/her settings enabled.
        """
        self.mentor_profile.receive_email_on_edit_report = True
        self.mentor_profile.save()

        ReportFactory.create(user=self.user, mentor=self.mentor)
        eq_(len(mail.outbox), 1)
開發者ID:josephbosire,項目名稱:remo,代碼行數:10,代碼來源:test_models.py

示例3: test_send_email_on_edit_report_with_receive_mail_False

    def test_send_email_on_edit_report_with_receive_mail_False(self):
        """Test sending an email when a report is edited.

           Default option: False
        """
        self.mentor_profile.receive_email_on_edit_report = False
        self.mentor_profile.receive_email_on_add_report = False
        self.mentor_profile.save()

        ReportFactory.create(user=self.user, mentor=self.mentor)
        eq_(len(mail.outbox), 0)
開發者ID:josephbosire,項目名稱:remo,代碼行數:11,代碼來源:test_models.py

示例4: setUp

 def setUp(self):
     """Initialize data for the tests."""
     self.mentor = UserFactory.create(username='counselor',
                                      groups=['Mentor'])
     self.user = UserFactory.create(
         username='rep', groups=['Rep'], userprofile__mentor=self.mentor,
         userprofile__date_joined_program=date(2011, 1, 1))
     ReportFactory.create(user=self.user, month=date(2012, 1, 1),
                          empty=False, overdue=True)
     ReportFactory.create(user=self.user, month=date(2012, 2, 1),
                          empty=True, overdue=False)
開發者ID:josephbosire,項目名稱:remo,代碼行數:11,代碼來源:test_util.py

示例5: test_view_report_page

 def test_view_report_page(self):
     """Test view report page."""
     # check that there is comment
     # check that there is comment form
     ReportFactory.create(user=self.user, empty=True, mentor=self.mentor,
                          month=datetime.date(2012, 1, 1))
     c = Client()
     response = c.get(reverse('reports_view_report',
                              kwargs={'display_name': self.up.display_name,
                                      'year': '2012',
                                      'month': 'January'}))
     self.assertTemplateUsed(response, 'view_report.html')
開發者ID:hoosteeno,項目名稱:remo,代碼行數:12,代碼來源:test_views.py

示例6: test_delete_report

    def test_delete_report(self):
        """Test delete report."""
        c = Client()
        ReportFactory.create(user=self.user, empty=True, mentor=self.mentor,
                             month=datetime.date(2012, 2, 1))
        delete_url = reverse('reports_delete_report',
                             kwargs={'display_name': self.up.display_name,
                                     'year': '2012',
                                     'month': 'February'})
        tmp_data = self.data.copy()
        tmp_data['delete_report'] = True

        # Test with anonymous user.
        response = c.post(delete_url, tmp_data, follow=True)
        self.assertTemplateUsed(response, 'main.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'warning')

        # Test with logged in user.
        c.login(username='counselor', password='passwd')
        response = c.post(delete_url, tmp_data, follow=True)
        self.assertTemplateUsed(response, 'main.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'error')

        # Test with owner.
        c.login(username='rep', password='passwd')
        response = c.post(delete_url, tmp_data, follow=True)
        self.assertTemplateUsed(response, 'main.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'error')

        # Test with mentor.
        c.login(username='rep', password='passwd')
        response = c.post(delete_url, tmp_data, follow=True)
        self.assertTemplateUsed(response, 'main.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'error')

        # Test with admin.
        c.login(username='admin', password='passwd')
        response = c.post(delete_url, tmp_data, follow=True)
        self.assertTemplateUsed(response, 'profiles_view.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'success')
開發者ID:hoosteeno,項目名稱:remo,代碼行數:50,代碼來源:test_views.py

示例7: test_delete_comment

    def test_delete_comment(self):
        """Test delete report comment."""
        report = ReportFactory.create(user=self.user, empty=True,
                                      mentor=self.mentor,
                                      month=datetime.date(2012, 2, 1))
        ReportCommentFactory.create(report=report, id=9, user=self.user)
        c = Client()
        delete_url = reverse('reports_delete_report_comment',
                             kwargs={'display_name': self.up.display_name,
                                     'year': '2012',
                                     'month': 'February',
                                     'comment_id': '9'})

        # Test with anonymous user.
        response = c.post(delete_url, {}, follow=True)
        self.assertTemplateUsed(response, 'main.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'warning')

        # Test with other user.
        c.login(username='counselor', password='passwd')
        response = c.post(delete_url, {}, follow=True)
        self.assertTemplateUsed(response, 'main.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'error')

        # Test with owner.
        c.login(username='rep', password='passwd')
        response = c.post(delete_url, {}, follow=True)
        self.assertTemplateUsed(response, 'main.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'error')

        # Test with user's mentor.
        c.login(username='mentor', password='passwd')
        response = c.post(delete_url, {}, follow=True)
        self.assertTemplateUsed(response, 'view_report.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'success')
        ok_(not ReportComment.objects.filter(pk=9).exists())

        # Test with admin.
        ReportCommentFactory.create(report=report, id=10, user=self.user)
        delete_url = reverse('reports_delete_report_comment',
                             kwargs={'display_name': self.up.display_name,
                                     'year': '2012',
                                     'month': 'February',
                                     'comment_id': '10'})
        c.login(username='admin', password='passwd')
        response = c.post(delete_url, {}, follow=True)
        self.assertTemplateUsed(response, 'view_report.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'success')
        ok_(not ReportComment.objects.filter(pk=10).exists())
開發者ID:hoosteeno,項目名稱:remo,代碼行數:59,代碼來源:test_views.py

示例8: test_view_edit_report_page

    def test_view_edit_report_page(self):
        """Test view edit report page."""
        # test my edit report
        # test without permission other user's
        # test with permission other user's
        # test with report from the future
        ReportFactory.create(user=self.user, empty=True, mentor=self.mentor,
                             month=datetime.date(2011, 2, 1))

        edit_page_url = reverse('reports_edit_report',
                                kwargs={'display_name': self.up.display_name,
                                        'year': '2011',
                                        'month': 'February'})

        # Try to access edit report page as anonymous.
        c = Client()
        response = c.get(edit_page_url, follow=True)
        self.assertTemplateUsed(response, 'main.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'warning')

        # Try to access edit report page as owner.
        c.login(username='rep', password='passwd')
        response = c.get(edit_page_url, follow=True)
        self.assertTemplateUsed(response, 'edit_report.html')

        # Try to access edit report page as admin.
        c.login(username='admin', password='passwd')
        response = c.get(edit_page_url, follow=True)
        self.assertTemplateUsed(response, 'edit_report.html')

        # Try to access edit report page as user's mentor.
        c.login(username='mentor', password='passwd')
        response = c.get(edit_page_url, follow=True)
        self.assertTemplateUsed(response, 'edit_report.html')

        # Try to access edit report page as other user.
        c.login(username='counselor', password='passwd')
        response = c.get(edit_page_url, follow=True)
        self.assertTemplateUsed(response, 'main.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'error')
開發者ID:hoosteeno,項目名稱:remo,代碼行數:44,代碼來源:test_views.py

示例9: setUp

 def setUp(self):
     self.date = datetime.datetime.now()
     self.mentor = UserFactory.create(username='counselor',
                                      groups=['Mentor'])
     self.user = UserFactory.create(username='rep', groups=['Rep'],
                                    userprofile__mentor=self.mentor)
     self.month_year = datetime.date(year=2012, month=1, day=10)
     self.new_report = ReportFactory.build(
         user=self.user, month=self.date,
         mentor=self.user.userprofile.mentor)
     self.mentor_profile = self.mentor.userprofile
開發者ID:josephbosire,項目名稱:remo,代碼行數:11,代碼來源:test_models.py

示例10: test_overdue_true_2

    def test_overdue_true_2(self, fake_requests_obj):
        """Test overdue report (second test)."""
        today = datetime.datetime.today()

        # act like it's OVERDUE_DAY + 1
        fake_date = datetime.datetime(year=today.year, month=today.month,
                                      day=OVERDUE_DAY + 1)
        (fake_requests_obj.expects_call().returns(fake_date))

        month_year = go_back_n_months(today)
        report = ReportFactory.create(user=self.user, month=month_year)
        eq_(report.overdue, True)
開發者ID:josephbosire,項目名稱:remo,代碼行數:12,代碼來源:test_models.py

示例11: test_overdue_false_2

    def test_overdue_false_2(self, fake_requests_obj):
        """Test not overdue report (first test)."""
        # marginal case
        today = datetime.datetime.today()

        # act like it's OVERDUE_DAY
        fake_date = datetime.datetime(year=today.year, month=today.month,
                                      day=OVERDUE_DAY)
        (fake_requests_obj.expects_call().returns(fake_date))

        month_year = go_back_n_months(today)
        report = ReportFactory.create(user=self.user, month=month_year)
        eq_(report.overdue, False)
開發者ID:josephbosire,項目名稱:remo,代碼行數:13,代碼來源:test_models.py

示例12: test_view_current_report_page

    def test_view_current_report_page(self):
        """Test view report page."""
        # If anonymous, return an error.
        c = Client()
        response = c.get(reverse('reports_view_current_report'), follow=True)
        self.assertTemplateUsed(response, 'main.html')
        for m in response.context['messages']:
            pass
        eq_(m.tags, u'warning')

        # Login.
        c.login(username='rep', password='passwd')

        # If report does not exist, render edit page.
        response = c.get(reverse('reports_view_current_report'), follow=True)
        self.assertTemplateUsed(response, 'edit_report.html')

        # If report exists, render report.
        ReportFactory.create(user=self.user, empty=True, mentor=self.mentor,
                             month=go_back_n_months(datetime.date.today()))
        response = c.get(reverse('reports_view_current_report'), follow=True)
        self.assertTemplateUsed(response, 'view_report.html')
開發者ID:hoosteeno,項目名稱:remo,代碼行數:22,代碼來源:test_views.py

示例13: test_overdue_false

 def test_overdue_false(self):
     """Test not overdue report (first test)."""
     # Change report created_on, so report is not overdue
     month_year = datetime.date(year=2020, month=1, day=10)
     report = ReportFactory.create(user=self.user, month=month_year)
     eq_(report.overdue, False)
開發者ID:josephbosire,項目名稱:remo,代碼行數:6,代碼來源:test_models.py


注:本文中的remo.reports.tests.ReportFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。