def test_admins_emailed(self): question = models.Question() question.author = self.user question.subject = "Hey" question.body = "Sort it out!" question.save() self.assertEqual(len(mail.outbox), 1) question2 = models.Question.objects.get(id=question.id) question2.save() self.assertEqual(len(mail.outbox), 1)
def test_last_activity(self): question = models.Question() question.author = self.user question.subject = "Hey" question.body = "Sort it out!" question.save() question.refresh_from_db() question_qs = models.Question.objects.annotate( last_response_date=Max("response__date")) self.assertEqual(question_qs[0].last_activity, question.last_modified) response = models.Response() response.question = question response.author = self.user response.body = "Oook" response.save() response.refresh_from_db() question_qs = models.Question.objects.annotate( last_response_date=Max("response__date")) self.assertEqual(question_qs[0].last_activity, response.date)