當前位置: 首頁>>代碼示例>>Python>>正文


Python Mock.command方法代碼示例

本文整理匯總了Python中asynctest.mock.Mock.command方法的典型用法代碼示例。如果您正苦於以下問題:Python Mock.command方法的具體用法?Python Mock.command怎麽用?Python Mock.command使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在asynctest.mock.Mock的用法示例。


在下文中一共展示了Mock.command方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_handle_command__other_command

# 需要導入模塊: from asynctest.mock import Mock [as 別名]
# 或者: from asynctest.mock.Mock import command [as 別名]
 async def test_handle_command__other_command(self, handle_command):
     from randtalkbot.admin_handler import StrangerHandler
     message = Mock()
     message.command = 'foo_command'
     message.command_args = 'foo_args'
     await self.admin_handler.handle_command(message)
     handle_command.assert_called_once_with(message)
開發者ID:quasiyoke,項目名稱:RandTalkBot,代碼行數:9,代碼來源:test_admin_handler.py

示例2: test_handle_command__not_activated_command_start

# 需要導入模塊: from asynctest.mock import Mock [as 別名]
# 或者: from asynctest.mock.Mock import command [as 別名]
 async def test_handle_command__not_activated_command_start(self):
     self.stranger.wizard = "none"
     message = Mock()
     message.command = "start"
     self.stranger_setup_wizard.handle = CoroutineMock(return_value=True)
     self.assertFalse((await self.stranger_setup_wizard.handle_command(message)))
     self.stranger_setup_wizard.handle.assert_called_once_with(message)
開發者ID:quasiyoke,項目名稱:RandTalkBot,代碼行數:9,代碼來源:test_stranger_setup_wizard.py

示例3: test_handle_command__telegram_error

# 需要導入模塊: from asynctest.mock import Mock [as 別名]
# 或者: from asynctest.mock.Mock import command [as 別名]
    async def test_handle_command__telegram_error(self):
        from randtalkbot.stranger_setup_wizard import LOGGER

        self.stranger.wizard = "setup"
        self.stranger.wizard_step = "sex"
        self.stranger.is_full.return_value = False
        self.stranger_setup_wizard._prompt = CoroutineMock()
        message = Mock()
        message.command = "begin"
        self.sender.send_notification.side_effect = TelegramError({}, "", 0)
        self.assertTrue((await self.stranger_setup_wizard.handle_command(message)))
        self.assertTrue(LOGGER.warning.called)
開發者ID:quasiyoke,項目名稱:RandTalkBot,代碼行數:14,代碼來源:test_stranger_setup_wizard.py

示例4: test_handle_command__not_full_stranger

# 需要導入模塊: from asynctest.mock import Mock [as 別名]
# 或者: from asynctest.mock.Mock import command [as 別名]
 async def test_handle_command__not_full_stranger(self):
     self.stranger.wizard = "setup"
     self.stranger.wizard_step = "sex"
     self.stranger.is_full.return_value = False
     self.stranger_setup_wizard._prompt = CoroutineMock()
     message = Mock()
     message.command = "begin"
     self.assertTrue((await self.stranger_setup_wizard.handle_command(message)))
     self.sender.send_notification.assert_called_once_with(
         "Finish setup process please. After that you can start using bot."
     )
     self.stranger_setup_wizard._prompt.assert_called_once_with()
開發者ID:quasiyoke,項目名稱:RandTalkBot,代碼行數:14,代碼來源:test_stranger_setup_wizard.py

示例5: test_handle_command__full_stranger

# 需要導入模塊: from asynctest.mock import Mock [as 別名]
# 或者: from asynctest.mock.Mock import command [as 別名]
 async def test_handle_command__full_stranger(self):
     self.stranger.wizard = "setup"
     self.stranger.wizard_step = "sex"
     self.stranger.is_full.return_value = True
     self.stranger_setup_wizard._prompt = CoroutineMock()
     self.stranger_setup_wizard.deactivate = CoroutineMock()
     message = Mock()
     message.command = "begin"
     self.assertFalse((await self.stranger_setup_wizard.handle_command(message)))
     self.stranger.is_full.assert_called_once_with()
     self.stranger_setup_wizard._prompt.assert_not_called()
     self.stranger_setup_wizard.deactivate.assert_called_once_with()
開發者ID:quasiyoke,項目名稱:RandTalkBot,代碼行數:14,代碼來源:test_stranger_setup_wizard.py

示例6: test_on_chat_message__command_setup

# 需要導入模塊: from asynctest.mock import Mock [as 別名]
# 或者: from asynctest.mock.Mock import command [as 別名]
 async def test_on_chat_message__command_setup(self, handle_command_mock):
     from randtalkbot.stranger_handler import Message
     from randtalkbot.stranger_handler import telepot
     telepot.glance.return_value = 'text', 'private', 31416
     message_json = {
         'text': 'some_command_text'
         }
     message = Mock()
     message.command = 'foo_command'
     Message.return_value = message
     self.stranger_setup_wizard.handle_command.return_value = True
     await self.stranger_handler.on_chat_message(message_json)
     self.stranger.send_to_partner.assert_not_called()
     Message.assert_called_once_with(message_json)
     handle_command_mock.assert_not_called()
開發者ID:quasiyoke,項目名稱:RandTalkBot,代碼行數:17,代碼來源:test_stranger_handler.py

示例7: test_handle_command__unknown_command

# 需要導入模塊: from asynctest.mock import Mock [as 別名]
# 或者: from asynctest.mock.Mock import command [as 別名]
 async def test_handle_command__unknown_command(self):
     message = Mock()
     message.command = 'foo_command'
     with self.assertRaises(UnknownCommandError):
         await self.stranger_handler.handle_command(message)
開發者ID:quasiyoke,項目名稱:RandTalkBot,代碼行數:7,代碼來源:test_stranger_handler.py

示例8: test_handle_command__ok

# 需要導入模塊: from asynctest.mock import Mock [as 別名]
# 或者: from asynctest.mock.Mock import command [as 別名]
 async def test_handle_command__ok(self):
     message = Mock()
     message.command = 'foo_command'
     self.stranger_handler._handle_command_foo_command = CoroutineMock()
     await self.stranger_handler.handle_command(message)
     self.stranger_handler._handle_command_foo_command.assert_called_once_with(message)
開發者ID:quasiyoke,項目名稱:RandTalkBot,代碼行數:8,代碼來源:test_stranger_handler.py


注:本文中的asynctest.mock.Mock.command方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。