def test_telegram_bot_main_with_won_message(self, mock_send_message,
                                                mock_add_history):
        chat_id = 'random_chat_id'
        event = _generate_event(chat_id=chat_id,
                                user_id='admin',
                                message='/won')

        lambda_function.telegram_bot_main(event)

        mock_send_message.assert_called_with(lambda_function.amount_msg(False),
                                             chat_id)
        mock_add_history.assert_called_with(event)
    def test_telegram_bot_main_with_unknown_messages(self, mock_send_message,
                                                     mock_add_history):
        chat_id = 'random_chat_id'

        for unknown_message in [
                'unknown_message', '-123', '0', '1.5', '2,500'
        ]:
            with self.subTest(unknown_message=unknown_message):
                event = _generate_event(chat_id=chat_id,
                                        user_id='admin',
                                        message=unknown_message)

                lambda_function.telegram_bot_main(event)

                mock_send_message.assert_called_with(
                    lambda_function.unknown_msg(), chat_id)
                mock_add_history.assert_called_with(event)
    def test_telegram_bot_main_with_positive_numeric_message_and_unknown_previous_messages(
            self, mock_send_message, mock_add_history, mock_previous_message):
        chat_id = 'random_chat_id'
        user_id = 'admin'

        for previous_message in ['unknown_message', '-123', '0']:
            with self.subTest():
                event = _generate_event(chat_id=chat_id,
                                        user_id=user_id,
                                        message='123')

                mock_previous_message.return_value = previous_message
                lambda_function.telegram_bot_main(event)

                mock_previous_message.assert_called_with(user_id)
                mock_send_message.assert_called_with(
                    lambda_function.unknown_msg(), chat_id)
                mock_add_history.assert_called_with(event)