def test_get_lasts_messages_of_threads_check_is_notification_check_who_read(self):
# participant 1 and 2 have read the messages, 3 no
self.participation1.date_last_check = now() + timedelta(days=1)
self.participation1.save()
self.participation2.date_last_check = now() + timedelta(days=1)
self.participation2.save()
# we create a notification check
with self.assertNumQueries(6):
messages = Message.managers.get_lasts_messages_of_threads(self.participant1.id, check_who_read=True, check_is_notification=True)
# the ordering has not been modified
self.assertEqual([self.m33.id, self.m22.id, self.m11.id], [m.id for m in messages])
# the second conversation has no notification because last reply comes from the current participant
self.assertEqual(messages[1].is_notification, False)
# the third (first in ordering) conversation has new messages
self.assertEqual(messages[0].is_notification, True)
# participant 1 and 2 have read Thread 1
self.assertTrue(self.participant1.id in messages[2].readers)
评论列表
文章目录