Пример #1
0
    def test_warning(self):
        feedback_relation = self.create_feedback_relation(
            deadline=timezone.now().date() + timedelta(days=2))
        message = FeedbackMail.generate_message(feedback_relation, self.logger)

        self.assertEqual(message.status, "Warning message")
        self.assertTrue(message.send)
Пример #2
0
    def test_first_mail(self):
        feedback_relation = self.create_feedback_relation()
        message = FeedbackMail.generate_message(feedback_relation, self.logger)

        self.assertEqual(message.status, "First message")
        self.assertTrue(message.send)
        self.assertTrue(feedback_relation.first_mail_sent)
Пример #3
0
    def test_deadline_passeed(self):
        feedback_relation = self.create_feedback_relation(
            deadline=self.yesterday().date())
        message = FeedbackMail.generate_message(feedback_relation, self.logger)

        self.assertEqual(message.status, "Deadine passed")
        self.assertFalse(feedback_relation.active)
Пример #4
0
    def test_user_answered(self):
        feedback_relation = self.create_feedback_relation()
        feedback_relation.answered.set([self.user1])
        message = FeedbackMail.generate_message(feedback_relation, self.logger)

        not_answered = [self.user2.email]
        self.assertEqual(set(message.attended_mails), set(not_answered))
Пример #5
0
    def test_event_not_done(self):
        feedback_relation = self.create_feedback_relation(
            end_date=timezone.now())
        message = FeedbackMail.generate_message(feedback_relation, self.logger)

        self.assertEqual(message.status, "Event not done")
        self.assertFalse(message.send)
Пример #6
0
    def test_no_message(self):
        feedback_relation = self.create_feedback_relation(
            end_date=timezone.now() - timedelta(days=2))
        feedback_relation.first_mail_sent = True
        message = FeedbackMail.generate_message(feedback_relation, self.logger)

        self.assertEqual(message.status, "No message generated")
        self.assertFalse(message.send)
Пример #7
0
    def test_everyone_answered(self):
        feedback_relation = self.create_feedback_relation()
        feedback_relation.answered.set([self.user1, self.user2])
        message = FeedbackMail.generate_message(feedback_relation, self.logger)

        self.assertEqual(message.status, 'Everyone has answered')
        self.assertFalse(message.send)
        self.assertFalse(feedback_relation.active)
Пример #8
0
    def test_users_mail_addresses(self):
        feedback_relation = self.create_feedback_relation()

        # The below if user.id check is due to Django Guardian middleware needing an AnonymousUser, that has ID -1
        user_mails = [
            user.email for user in User.objects.all()
            if user.username != settings.ANONYMOUS_USER_NAME
        ]

        message = FeedbackMail.generate_message(feedback_relation, self.logger)
        self.assertEqual(set(message.attended_mails), set(user_mails))