def test_with_no_report_filled_and_one_notification(self): mentor = UserFactory.create(groups=['Mentor']) today = now().date() rep = UserFactory.create(groups=['Rep'], userprofile__mentor=mentor, userprofile__first_report_notification=today - timedelta(weeks=4)) NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=9)) rep_subject = '[Reminder] Please share your recent activities' mentor_subject = '[Report] Mentee without report for the last 8 weeks' with patch('remo.reports.utils.send_remo_mail') as mail_mock: send_second_report_notification() eq_(mail_mock.call_count, 2) expected_call_list = [ call(subject=rep_subject, recipients_list=[rep.email], message=mockany, sender=mentor.email), call(subject=mentor_subject, recipients_list=[mentor.email], message=mockany, sender=rep.email) ] eq_(mail_mock.call_args_list, expected_call_list)
def test_with_report_filled(self): mentor = UserFactory.create(groups=["Mentor"]) today = now().date() rep = UserFactory.create(groups=["Rep"], userprofile__mentor=mentor) NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=2)) with patch("remo.reports.utils.send_remo_mail") as mail_mock: send_second_report_notification() ok_(not mail_mock.called)
def test_with_report_filled(self): mentor = UserFactory.create(groups=['Mentor']) today = now().date() rep = UserFactory.create(groups=['Rep'], userprofile__mentor=mentor) NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=2)) with patch('remo.reports.utils.send_remo_mail') as mail_mock: send_second_report_notification() ok_(not mail_mock.called)
def test_with_no_report_filled_and_one_notification(self): mentor = UserFactory.create(groups=['Mentor']) today = now().date() rep = UserFactory.create( groups=['Rep'], userprofile__mentor=mentor, userprofile__first_report_notification=today - timedelta(weeks=4)) NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=9)) rep_subject = '[Reminder] Please share your recent activities' mentor_subject = '[Report] Mentee without report for the last 8 weeks' with patch('remo.reports.utils.send_remo_mail') as mail_mock: send_second_report_notification() eq_(mail_mock.call_count, 2) expected_call_list = [ call(rep_subject, [rep.email], message=mockany), call(mentor_subject, [mentor.email], message=mockany)] eq_(mail_mock.call_args_list, expected_call_list)