def test__send_image_message_shoul_call_sendMessage_api_correctly(self): tcb = TelegramController() tcb.post_worker = MagicMock() tcb.TOKEN = "banana" tcb.CHAT_ID = "to_banana" tcb._send_http = MagicMock() tcb._send_image_message("banana_file") tcb.post_worker.post_task.assert_called_once_with(ANY) task = tcb.post_worker.post_task.call_args[0][0] tcb.post_worker.post_task.call_args[0][0]["runnable"](task) tcb._send_http.assert_called_once_with( "https://api.telegram.org/banana/sendPhoto?chat_id=to_banana", True, "banana_file")
def test__query_score_should_call_next_setup_message_correctly_when_step_1( self): tcb = TelegramController() tcb.in_progress_step = 1 tcb.operator = MagicMock() tcb._send_text_message = MagicMock() tcb._send_image_message = MagicMock() tcb._query_score("1") tcb.operator.get_score.assert_called_once() tcb._send_text_message.assert_called_once_with("조회중입니다", tcb.main_keyboard) self.assertEqual(tcb.in_progress, None) self.assertEqual(tcb.in_progress_step, 0) self.assertEqual(tcb.operator.get_score.call_args[0][1], (60 * 6, -1)) callback = tcb.operator.get_score.call_args[0][0] callback(None) tcb._send_text_message.assert_called_with("수익률 조회중 문제가 발생하였습니다.", tcb.main_keyboard) callback((100, 200, 0.5, 0.9, "test.jpg", 0, 0, 0, ("12-01", "12-05", "12-08"))) tcb._send_text_message.assert_called_with( "12-05 - 12-08\n자산 100 -> 200\n구간 수익률 100.0\n12-01~\n누적 수익률 0.5\n비교 수익률 0.9\n", tcb.main_keyboard, ) tcb._send_image_message.assert_called_with("test.jpg")