test_webhook.py 文件源码

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

项目:PilosusBot 作者: pilosus 项目源码 文件源码
def test_handle_malformed_Message(self, mocked_send_to_chat, mocked_celery_chain):
        response = self.client.post(TelegramUpdates.URL_HANDLE_WEBHOOK,
                                    data=json.dumps(TelegramUpdates.TEXT_MALFORMED_NO_MESSAGE),
                                    follow_redirects=True,
                                    headers=TelegramUpdates.HEADERS)
        self.assertTrue(response.status_code == 200,
                        'Failed to return status code 200 for an Update with '
                        'a malformed Message')
        self.assertEqual({}, json.loads(response.data),
                         'Failed to return an empty JSON for an Update with '
                         'a malformed Message')

        mocked_send_to_chat.apply_async.assert_called_with(args=[{}])

        with self.assertRaises(AssertionError) as chain_err:
            mocked_celery_chain.assert_called()

        self.assertIn("Expected 'celery_chain' to have been called",
                      str(chain_err.exception))
        self.assertEqual(mocked_celery_chain.call_args_list, [])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号