test_models.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:django-rest-messaging 作者: raphaelgyory 项目源码 文件源码
def test_get_lasts_messages_of_threads_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 do not modify self.participation3.date_last_check
        # this means participant 1 and 2 have read the message, not 3
        with self.assertNumQueries(5):
            messages = Message.managers.get_lasts_messages_of_threads(self.participant1.id, check_who_read=True, check_is_notification=False)
            # the ordering has not been modified
            self.assertEqual([self.m33.id, self.m22.id, self.m11.id], [m.id for m in messages])
            # participant 1 and 2 have read Thread 1
            self.assertTrue(self.participant1.id in messages[2].readers)
            self.assertTrue(self.participant2.id in messages[2].readers)
            self.assertFalse(self.participant3.id in messages[0].readers)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号