def test_with_no_report_filled_and_one_notification(self): mentor = UserFactory.create(groups=['Mentor']) today = datetime.utcnow().date() rep = UserFactory.create( groups=['Rep'], userprofile__mentor=mentor, userprofile__last_report_notification=today - timedelta(weeks=1)) NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=2)) with patch('remo.reports.tasks.send_mail') as send_mail_mock: send_ng_report_notification() ok_(not send_mail_mock.called)
def test_with_report_filled(self): mentor = UserFactory.create(groups=['Mentor']) today = datetime.utcnow().date() rep = UserFactory.create(groups=['Rep'], userprofile__mentor=mentor, userprofile__last_report_notification=today - timedelta(weeks=4)) NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=2)) with patch('remo.reports.tasks.send_mail') as send_mail_mock: send_ng_report_notification() ok_(not send_mail_mock.called)
def test_base(self): mentor = UserFactory.create(groups=['Mentor']) today = datetime.utcnow().date() rep = UserFactory.create( groups=['Rep'], userprofile__mentor=mentor, userprofile__last_report_notification=today - timedelta(weeks=4)) NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=5)) subject = '[Reminder] Please share your recent activities' with patch('remo.reports.tasks.send_mail') as send_mail_mock: send_ng_report_notification() send_mail_mock.assert_called_with( subject, mockany, settings.FROM_EMAIL, [rep.email])
def test_base(self): mentor = UserFactory.create(groups=['Mentor']) today = datetime.utcnow().date() rep = UserFactory.create(groups=['Rep'], userprofile__mentor=mentor, userprofile__last_report_notification=today - timedelta(weeks=4)) NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=5)) subject = '[Reminder] Please share your recent activities' with patch('remo.reports.tasks.send_mail') as send_mail_mock: send_ng_report_notification() send_mail_mock.assert_called_with(subject, mockany, settings.FROM_EMAIL, [rep.email])
def test_base(self): mentor = UserFactory.create(groups=['Mentor']) today = now().date() rep = UserFactory.create( groups=['Rep'], userprofile__mentor=mentor, userprofile__last_report_notification=today - timedelta(weeks=4)) 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 3 weeks' with patch('remo.reports.tasks.send_mail') as send_mail_mock: send_ng_report_notification() eq_(send_mail_mock.call_count, 2) expected_call_list = [ call(rep_subject, mockany, settings.FROM_EMAIL, [rep.email]), call(mentor_subject, mockany, settings.FROM_EMAIL, [mentor.email])] eq_(send_mail_mock.call_args_list, expected_call_list)