def test_base(self): mentor = UserFactory.create(groups=['Mentor']) today = now().date() rep = UserFactory.create( groups=['Rep'], userprofile__mentor=mentor, userprofile__date_joined_program=get_date(days=-100)) NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=5)) rep_subject = '[Reminder] Please share your recent activities' mentor_subject = '[Report] Mentee without report for the last 4 weeks' with patch('remo.reports.utils.send_remo_mail') as mail_mock: send_first_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_user_unavailable(self): mentor = UserFactory.create(groups=["Mentor"]) today = now().date() rep = UserFactory.create( groups=["Rep"], userprofile__mentor=mentor, userprofile__date_joined_program=get_date(days=-100) ) UserStatusFactory.create(user=rep) NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=5)) with patch("remo.reports.utils.send_remo_mail") as mail_mock: send_first_report_notification() ok_(not mail_mock.called)
def test_with_user_unavailable(self): mentor = UserFactory.create(groups=['Mentor']) today = now().date() rep = UserFactory.create( groups=['Rep'], userprofile__mentor=mentor, userprofile__date_joined_program=get_date(days=-100), userprofile__is_unavailable=True) NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=5)) with patch('remo.reports.utils.send_remo_mail') as mail_mock: send_first_report_notification() ok_(not mail_mock.called)
def test_with_alumnus_mentor(self): mentor = UserFactory.create(groups=["Mentor", "Alumni"]) today = now().date() rep = UserFactory.create(groups=["Rep"], userprofile__date_joined_program=get_date(days=-100)) NGReportFactory.create(user=rep, mentor=mentor, report_date=today - timedelta(weeks=5)) rep_subject = "[Reminder] Please share your recent activities" with patch("remo.reports.utils.send_remo_mail") as mail_mock: send_first_report_notification() eq_(mail_mock.call_count, 1) expected_call_list = [call(rep_subject, [rep.email], message=mockany)] eq_(mail_mock.call_args_list, expected_call_list)
def test_with_alumnus_mentor(self): mentor = UserFactory.create(groups=['Mentor', 'Alumni']) today = now().date() rep = UserFactory.create( groups=['Rep'], userprofile__date_joined_program=get_date(days=-100)) NGReportFactory.create(user=rep, mentor=mentor, report_date=today - timedelta(weeks=5)) rep_subject = '[Reminder] Please share your recent activities' with patch('remo.reports.utils.send_remo_mail') as mail_mock: send_first_report_notification() eq_(mail_mock.call_count, 1) expected_call_list = [call(rep_subject, [rep.email], message=mockany)] eq_(mail_mock.call_args_list, expected_call_list)
def test_base(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=5)) rep_subject = '[Reminder] Please share your recent activities' mentor_subject = '[Report] Mentee without report for the last 4 weeks' with patch('remo.reports.utils.send_remo_mail') as mail_mock: send_first_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)
def test_base(self): mentor = UserFactory.create(groups=["Mentor"]) today = now().date() rep = UserFactory.create( groups=["Rep"], userprofile__mentor=mentor, userprofile__date_joined_program=get_date(days=-100) ) NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=5)) rep_subject = "[Reminder] Please share your recent activities" mentor_subject = "[Report] Mentee without report for the last 4 weeks" with patch("remo.reports.utils.send_remo_mail") as mail_mock: send_first_report_notification() eq_(mail_mock.call_count, 2) expected_call_list = [ call(rep_subject, [rep.email], message=mockany, headers={"Reply-To": mentor.email}), call(mentor_subject, [mentor.email], message=mockany, headers={"Reply-To": rep.email}), ] eq_(mail_mock.call_args_list, expected_call_list)