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, [])
评论列表
文章目录