Example #1
0
    def test_email(self):
        """
        If there is a video submitted in the previous day, an e-mail should be
        sent
        """
        self._set_notification(self.admin, True)
        self._set_notification(self.superuser, True)
        queue_videos = Video.objects.filter(status=Video.UNAPPROVED)

        new_video = queue_videos[0]
        new_video.when_submitted = datetime.datetime.now() - \
            datetime.timedelta(hours=23, minutes=59)
        new_video.save()

        review_status_email.Command().handle_noargs()
        self.assertEqual(len(mail.outbox), 1)

        message = mail.outbox[0]
        self.assertEqual(message.subject, 'Video Submissions for example.com')
        t = loader.get_template('localtv/submit_video/review_status_email.txt')
        c = Context({
            'queue_videos': queue_videos,
            'new_videos': queue_videos.filter(pk=new_video.pk),
            'time_period': 'today',
            'site': Site.objects.get_current()
        })
        self.assertEqual(message.body, t.render(c))
Example #2
0
    def test_email(self):
        """
        If there is a video submitted in the previous day, an e-mail should be
        sent
        """
        queue_videos = models.Video.objects.filter(
            status=models.VIDEO_STATUS_UNAPPROVED)

        new_video = queue_videos[0]
        new_video.when_submitted = datetime.datetime.now() - \
            datetime.timedelta(hours=23, minutes=59)
        new_video.save()

        review_status_email.Command().handle_noargs()
        self.assertEquals(len(mail.outbox), 1)

        message = mail.outbox[0]
        self.assertEquals(message.subject, 'Video Submissions for testserver')
        t = loader.get_template('localtv/submit_video/review_status_email.txt')
        c = Context({
            'queue_videos': queue_videos,
            'new_videos': queue_videos.filter(pk=new_video.pk),
            'time_period': 'today',
            'site': self.site_location.site
        })
        self.assertEquals(message.body, t.render(c))
Example #3
0
    def test_no_email(self):
        """
        If admins are subscribed, but no videos are new in the previous day,
        no e-mail should be sent.

        """
        self._set_notification(self.admin, True)
        self._set_notification(self.superuser, True)
        review_status_email.Command().handle_noargs()
        self.assertEqual(len(mail.outbox), 0)
Example #4
0
    def test_no_email_without_setting(self):
        """
        If no admins are subscribed, no e-mail should be sent.
        """
        self._set_notification(self.admin, False)
        self._set_notification(self.superuser, False)

        queue_videos = Video.objects.filter(status=Video.UNAPPROVED)

        new_video = queue_videos[0]
        new_video.when_submitted = datetime.datetime.now()
        new_video.save()

        review_status_email.Command().handle_noargs()
        self.assertEqual(len(mail.outbox), 0)
Example #5
0
    def test_no_email_without_setting(self):
        """
        If no admins are subscribed, no e-mail should be sent.
        """
        notice_type = notification.NoticeType.objects.get(
            label='admin_queue_daily')
        for username in 'admin', 'superuser':
            user = User.objects.get(username=username)
            setting = notification.get_notification_setting(user, notice_type,
                                                            "1")
            setting.send = False
            setting.save()

        queue_videos = Video.objects.filter(
            status=Video.UNAPPROVED)

        new_video = queue_videos[0]
        new_video.when_submitted = datetime.datetime.now()
        new_video.save()

        review_status_email.Command().handle_noargs()
        self.assertEqual(len(mail.outbox), 0)
Example #6
0
 def test_no_email(self):
     """
     If no videos are new in the previous day, no e-mail should be sent.
     """
     review_status_email.Command().handle_noargs()
     self.assertEqual(len(mail.outbox), 0)