本文整理汇总了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)
示例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)
示例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)
示例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)
示例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')
示例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')
示例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())
示例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')
示例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
示例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)
示例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)
示例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')
示例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)