当前位置: 首页>>代码示例>>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;未经允许,请勿转载。