test.py 文件源码

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

项目:hearthscan-bot 作者: d-schmidt 项目源码 文件源码
def test_AnswerMail_Success(self):
        r = MagicMock()

        msg = MagicMock()
        msg.subreddit = None
        msg.author.name = 'user'
        msg.id = 'msgid'
        msg.distinguished = None
        msg.subject = 'sub'
        msg.body = 'body'
        pmUserCache = { }

        helper = MagicMock()
        helper.parseText = MagicMock(return_value=(['card'], 'text'))

        # test
        hsbot.answerPM(r, msg, pmUserCache, helper)

        self.assertTrue('user' in pmUserCache, 'user added to cache')

        self.assertEqual(r.method_calls, [], 'no reddit calls')
        expected = [call.parseText('sub body')]
        self.assertEqual(helper.method_calls, expected, 'parseText')
        expected = [call.reply('text')]
        self.assertEqual(msg.method_calls, expected, 'reply')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号