def test_simple_email(self): num_followers = 5 self._create_followers(self.video, num_followers) notify_comment_by_email(self.comment) self.assertEqual(len(mail.outbox), num_followers) email = mail.outbox[0] self.assertEqual(email.subject, SUBJECT_EMAIL_VIDEO_COMMENTED % (self.comment.user.username, self.video.title_display())) return None
def post(request): output = dict(success=False) form = CommentForm(None, request.POST) if form.is_valid(): obj = form.save(request.user) output['success'] = True notify_comment_by_email(obj) else: output['errors'] = form.get_errors() return HttpResponse(json.dumps(output), "text/javascript")
def test_simple_email(self): num_followers = 5 self._create_followers(self.video, num_followers) mail.outbox = [] notify_comment_by_email(self.comment) self.assertEqual(len(mail.outbox), num_followers) email = mail.outbox[0] self.assertEqual( email.subject, SUBJECT_EMAIL_VIDEO_COMMENTED % (self.comment.user.username, self.video.title_display())) return None
def reject_version(version, team, user, rejection_message=None, sender=None, updates_meta=True, ): v = _set_version_moderation_status(version, team, user, REJECTED, updates_meta) latest = version.language.latest_version(public_only=False) if latest and latest.moderation_status == REJECTED: # rollback to the last moderated status latest_approved = version.language.latest_version(public_only=True) if latest_approved: latest_approved.rollback(user) if bool(rejection_message) and bool(sender): comment = create_comment_for_rejection(version, rejection_message, sender) notify_comment_by_email(comment, version.language, moderator = sender, is_rejection=True ) Action.create_rejected_video_handler(version, user) return v
def test_email_content(self): num_followers = 2 body_dicts = [] from utils import tasks send_templated_email_old = tasks.send_templated_email def send_templated_email(email, subject, template, body_dict, from_email=None, ct="html", fail_silently=False): body_dicts.append(body_dict) tasks.send_templated_email = send_templated_email self._create_followers(self.video, num_followers) notify_comment_by_email(self.comment) body_dict = body_dicts[0] self.assertEqual(self.comment.user.username, body_dict['commenter']) self.assertEqual(self.comment.user.get_absolute_url(), body_dict['commenter_url']) tasks.send_templated_email = send_templated_email_old