conversations_tests.py 文件源码

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

项目:mltshp 作者: MLTSHP 项目源码 文件源码
def test_muting_conversation(self):
        """
        Add a comment, which will create a conversation for the commenter (user2) and sharedfile owner (admin).

        When user2 tries to mute admin's conversation, it should fail and admin's conversation state will remain 
        unchanged.  When muting own converastion, "muted" flag should change to true.

        Contingent on user2 being signed in. (see setUp)
        """
        comment = Comment(sharedfile_id=self.shf.id, user_id=self.user2.id, body='test')
        comment.save()

        admin_conversation = Conversation.get('user_id = %s', self.admin.id)
        user2_conversation = Conversation.get('user_id = %s', self.user2.id)
        self.assertEqual(admin_conversation.muted, 0)
        self.assertEqual(user2_conversation.muted, 0)

        request = HTTPRequest(self.get_url('/conversations/%s/mute' % admin_conversation.id), 'POST', {'Cookie':'_xsrf=%s;sid=%s' % (self.xsrf, self.sid)}, "_xsrf=%s" % (self.xsrf))
        self.http_client.fetch(request, self.stop)
        response = self.wait()
        request = HTTPRequest(self.get_url('/conversations/%s/mute' % user2_conversation.id), 'POST', {'Cookie':'_xsrf=%s;sid=%s' % (self.xsrf, self.sid)}, "_xsrf=%s" % (self.xsrf))
        self.http_client.fetch(request, self.stop)
        response = self.wait()

        # refetch from DB, and verify mute flags remain 0.
        admin_conversation = Conversation.get('user_id = %s', self.admin.id)
        user2_conversation = Conversation.get('user_id = %s', self.user2.id)
        self.assertEqual(admin_conversation.muted, 0)
        self.assertEqual(user2_conversation.muted, 1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号