def test_dont_send_weekly_report(self): organizer = User.objects.create_user('*****@*****.**', '*****@*****.**', 'password') faci1 = User.objects.create_user('*****@*****.**', '*****@*****.**', 'password') StudyGroup.objects.filter(pk=1).update(facilitator=faci1) team = Team.objects.create(name='test team') TeamMembership.objects.create(team=team, user=organizer, role=TeamMembership.ORGANIZER) TeamMembership.objects.create(team=team, user=faci1, role=TeamMembership.MEMBER) study_group = StudyGroup.objects.get(pk=1) meeting = Meeting() meeting.study_group = study_group meeting.meeting_time = datetime.time(9) meeting.meeting_date = datetime.date(2018, 8, 14) meeting.save() study_group = StudyGroup.objects.get(pk=2) meeting = Meeting() meeting.study_group = study_group meeting.meeting_time = datetime.time(9) meeting.meeting_date = datetime.date(2018, 8, 14) meeting.save() with freeze_time("2018-08-28 10:01:00"): send_weekly_update() self.assertEqual(len(mail.outbox), 1) self.assertEqual(mail.outbox[0].to[0], '*****@*****.**')
def test_send_weekly_report(self): organizer = User.objects.create_user('*****@*****.**', '*****@*****.**', 'password') faci1 = User.objects.create_user('*****@*****.**', '*****@*****.**', 'password') StudyGroup.objects.filter(pk=1).update(facilitator=faci1) team = Team.objects.create(name='test team') TeamMembership.objects.create(team=team, user=organizer, role=TeamMembership.ORGANIZER) TeamMembership.objects.create(team=team, user=faci1, role=TeamMembership.MEMBER) study_group = StudyGroup.objects.get(pk=1) meeting = StudyGroupMeeting() meeting.study_group = study_group meeting.meeting_time = timezone.now().time() meeting.meeting_date = timezone.now().date() - datetime.timedelta(days=1) meeting.save() study_group = StudyGroup.objects.get(pk=2) meeting = StudyGroupMeeting() meeting.study_group = study_group meeting.meeting_time = timezone.now().time() meeting.meeting_date = timezone.now().date() - datetime.timedelta(days=1) meeting.save() send_weekly_update() self.assertEqual(len(mail.outbox), 2) self.assertEqual(mail.outbox[0].to[0], '*****@*****.**') self.assertEqual(mail.outbox[1].to[0], '*****@*****.**')
def weekly_update(): # Create a report for the previous week send_weekly_update()