Пример #1
0
 def test__start_trading_should_reset_with_wrong_input_when_step_1(self):
     tcb = TelegramController()
     tcb.in_progress_step = 1
     tcb._send_text_message = MagicMock()
     tcb._start_trading("5000.5")
     wrong_message = "자동 거래가 시작되지 않았습니다.\n처음부터 다시 시작해주세요"
     tcb._send_text_message.assert_called_once_with(wrong_message,
                                                    tcb.main_keyboard)
     self.assertEqual(tcb.in_progress, None)
     self.assertEqual(tcb.in_progress_step, 0)
Пример #2
0
    def test__start_trading_should_call_next_setup_message_correctly_when_step_1(
            self):
        tcb = TelegramController()
        tcb.in_progress_step = 1
        tcb._send_text_message = MagicMock()
        tcb._start_trading("5000")

        tcb._send_text_message.assert_called_once_with(
            tcb.setup_list[1]["guide"], tcb.setup_list[1]["keyboard"])
        self.assertEqual(tcb.in_progress, tcb._start_trading)
        self.assertEqual(tcb.in_progress_step, 2)
Пример #3
0
    def test__start_trading_should_call_next_setup_message_correctly_when_step_5(
            self, mock_start, mock_initialize):
        tcb = TelegramController()
        tcb.in_progress_step = 5
        tcb._send_text_message = MagicMock()
        tcb.strategy = MagicMock()
        tcb.trader = MagicMock()
        tcb._start_trading("y")

        tcb._send_text_message.assert_called_once_with(ANY, tcb.main_keyboard)
        self.assertIsNotNone(tcb.operator)
        self.assertEqual(tcb.in_progress, None)
        self.assertEqual(tcb.in_progress_step, 0)
Пример #4
0
    def test__start_trading_should_call_next_setup_message_correctly_when_step_3(
            self):
        tcb = TelegramController()
        tcb.in_progress_step = 3
        tcb._send_text_message = MagicMock()
        tcb.currency = "BTC"
        tcb._start_trading("upbit")

        tcb._send_text_message.assert_called_once_with(
            tcb.setup_list[3]["guide"], tcb.setup_list[3]["keyboard"])
        self.assertIsNotNone(tcb.trader)
        self.assertIsNotNone(tcb.data_provider)
        self.assertEqual(tcb.in_progress, tcb._start_trading)
        self.assertEqual(tcb.in_progress_step, 4)
Пример #5
0
    def test__start_trading_should_call_next_setup_message_correctly_when_step_4(
            self):
        tcb = TelegramController()
        tcb.in_progress_step = 4
        tcb._send_text_message = MagicMock()
        tcb.trader = MagicMock()
        tcb.currency = "mango"
        tcb.trader.NAME = "mango trader"
        tcb.strategy = MagicMock()
        tcb.strategy.NAME = "mango strategy"
        tcb.budget = 500
        tcb._start_trading("SMA")

        tcb._send_text_message.assert_called_once_with(
            f"화폐: mango\n전략: {StrategySma0.NAME}\n거래소: mango trader\n예산: 500\n자동 거래를 시작할까요?",
            tcb.setup_list[4]["keyboard"],
        )
        self.assertIsNotNone(tcb.strategy)
        self.assertEqual(tcb.in_progress, tcb._start_trading)
        self.assertEqual(tcb.in_progress_step, 5)