当前位置: 首页>>代码示例>>Python>>正文


Python Mock.command_args方法代码示例

本文整理汇总了Python中asynctest.mock.Mock.command_args方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.command_args方法的具体用法?Python Mock.command_args怎么用?Python Mock.command_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在asynctest.mock.Mock的用法示例。


在下文中一共展示了Mock.command_args方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_handle_command__other_command

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import command_args [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__start_no_invitation_is_in_setup

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import command_args [as 别名]
 async def test_handle_command__start_no_invitation_is_in_setup(self):
     message = Mock()
     message.command_args = ''
     self.stranger.wizard = 'setup'
     self.stranger.invited_by = None
     await self.stranger_handler._handle_command_start(message)
     self.assertEqual(self.stranger.invited_by, None)
     self.sender.send_notification.assert_not_called()
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:10,代码来源:test_stranger_handler.py

示例3: test_handle_command_pay__no_command_args

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import command_args [as 别名]
 async def test_handle_command_pay__no_command_args(self):
     from randtalkbot.admin_handler import StrangerService
     stranger_service = StrangerService.get_instance.return_value
     message = Mock()
     message.command_args = None
     await self.admin_handler._handle_command_pay(message)
     stranger_service.get_stranger.assert_not_called()
     self.sender.send_notification.assert_called_once_with(
         'Please specify Telegram ID and bonus amount like this: `/pay 31416 10 Thanks!`',
         )
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:12,代码来源:test_admin_handler.py

示例4: test_handle_command__start_no_invitation

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import command_args [as 别名]
 async def test_handle_command__start_no_invitation(self):
     message = Mock()
     message.command_args = ''
     self.stranger.wizard = 'none'
     self.stranger.invited_by = None
     await self.stranger_handler._handle_command_start(message)
     self.assertEqual(self.stranger.invited_by, None)
     self.sender.send_notification.assert_called_once_with(
         '*Manual*\n\nUse /begin to start looking for a conversational partner, once '
             'you\'re matched you can use /end to end the conversation.'
         )
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:13,代码来源:test_stranger_handler.py

示例5: test_handle_command_pay

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import command_args [as 别名]
 async def test_handle_command_pay(self):
     from randtalkbot.admin_handler import StrangerService
     stranger_service = StrangerService.get_instance.return_value
     stranger = CoroutineMock()
     stranger_service.get_stranger.return_value = stranger
     message = Mock()
     message.command_args = '31416 27183 foo gratitude'
     await self.admin_handler._handle_command_pay(message)
     stranger_service.get_stranger.assert_called_once_with(31416)
     stranger.pay.assert_called_once_with(27183, 'foo gratitude')
     self.sender.send_notification.assert_called_once_with('Success.')
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:13,代码来源:test_admin_handler.py

示例6: test_handle_command_clear

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import command_args [as 别名]
 async def test_handle_command_clear(self):
     from randtalkbot.admin_handler import StrangerService
     stranger = CoroutineMock()
     stranger_service = StrangerService.get_instance.return_value
     stranger_service.get_stranger.return_value = stranger
     message = Mock()
     message.command_args = '31416'
     await self.admin_handler._handle_command_clear(message)
     stranger_service.get_stranger.assert_called_once_with(31416)
     stranger.end_talk.assert_called_once_with()
     self.sender.send_notification.assert_called_once_with('Stranger {0} was cleared', 31416)
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:13,代码来源:test_admin_handler.py

示例7: test_handle_command_pay__unknown_stranger

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import command_args [as 别名]
 async def test_handle_command_pay__unknown_stranger(self):
     from randtalkbot.admin_handler import StrangerService
     stranger_service = StrangerService.get_instance.return_value
     error = StrangerServiceError()
     stranger_service.get_stranger.side_effect = error
     message = Mock()
     message.command_args = '31416 27183'
     await self.admin_handler._handle_command_pay(message)
     stranger_service.get_stranger.assert_called_once_with(31416)
     self.sender.send_notification.assert_called_once_with(
         'Stranger wasn\'t found: {0}',
         error,
         )
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:15,代码来源:test_admin_handler.py

示例8: test_handle_command_clear__incorrect_telegram_id

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import command_args [as 别名]
 async def test_handle_command_clear__incorrect_telegram_id(self):
     from randtalkbot.admin_handler import StrangerService
     stranger_service = StrangerService.get_instance.return_value
     message = Mock()
     message.command_args = 'foo'
     await self.admin_handler._handle_command_clear(message)
     stranger_service.get_stranger.assert_not_called()
     self.assertEqual(
         self.sender.send_notification.call_args_list,
         [
             call('Is it really telegram_id: \"{0}\"?', 'foo'),
             call('Use it this way: `/clear 31416 27183`'),
             ],
         )
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:16,代码来源:test_admin_handler.py

示例9: test_handle_command__start_has_invalid_invitation_json_type

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import command_args [as 别名]
 async def test_handle_command__start_has_invalid_invitation_json_type(self):
     from randtalkbot.stranger_handler import StrangerService
     message = Mock()
     message.command_args = 'foo_args'
     message.decode_command_args.return_value = [1, 2, 3]
     self.stranger.wizard = 'none'
     self.stranger.invited_by = None
     stranger_service = StrangerService.get_instance.return_value
     await self.stranger_handler._handle_command_start(message)
     stranger_service.get_stranger_by_invitation.assert_not_called()
     self.assertEqual(self.stranger.invited_by, None)
     self.sender.send_notification.assert_called_once_with(
         '*Manual*\n\nUse /begin to start looking for a conversational partner, once '
             'you\'re matched you can use /end to end the conversation.'
         )
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:17,代码来源:test_stranger_handler.py

示例10: test_handle_command_clear__unknown_stranger

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import command_args [as 别名]
 async def test_handle_command_clear__unknown_stranger(self):
     from randtalkbot.admin_handler import StrangerService
     error = StrangerServiceError()
     stranger_service = StrangerService.get_instance.return_value
     stranger_service.get_stranger.side_effect = error
     message = Mock()
     message.command_args = '31416'
     await self.admin_handler._handle_command_clear(message)
     stranger_service.get_stranger.assert_called_once_with(31416)
     self.assertEqual(
         self.sender.send_notification.call_args_list,
         [
             call('Stranger {0} wasn\'t found: {1}', 31416, error),
             call('Use it this way: `/clear 31416 27183`'),
             ],
         )
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:18,代码来源:test_admin_handler.py

示例11: test_handle_command__start_has_invitation_and_already_invited_by

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import command_args [as 别名]
 async def test_handle_command__start_has_invitation_and_already_invited_by(self):
     from randtalkbot.stranger_handler import StrangerService
     message = Mock()
     message.command_args = 'foo_args'
     message.decode_command_args.return_value = {'i': 'foo_invitation'}
     new_invited_by = CoroutineMock()
     stranger_service = StrangerService.get_instance.return_value
     stranger_service.get_stranger_by_invitation.return_value = new_invited_by
     self.stranger.wizard = 'none'
     invited_by = CoroutineMock()
     self.stranger.invited_by = invited_by
     await self.stranger_handler._handle_command_start(message)
     stranger_service.get_stranger_by_invitation.assert_not_called()
     self.assertEqual(self.stranger.invited_by, invited_by)
     self.sender.send_notification.assert_called_once_with(
         '*Manual*\n\nUse /begin to start looking for a conversational partner, once '
             'you\'re matched you can use /end to end the conversation.'
         )
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:20,代码来源:test_stranger_handler.py

示例12: test_handle_command__start_has_invited_himself

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import command_args [as 别名]
 async def test_handle_command__start_has_invited_himself(self):
     from randtalkbot.stranger_handler import StrangerService
     message = Mock()
     message.command_args = 'foo_args'
     message.decode_command_args.return_value = {'i': 'foo_invitation'}
     self.stranger.wizard = 'none'
     self.stranger.invited_by = None
     self.stranger.invitation = 'foo_invitation'
     stranger_service = StrangerService.get_instance.return_value
     await self.stranger_handler._handle_command_start(message)
     stranger_service.get_stranger_by_invitation.assert_not_called()
     self.assertEqual(self.stranger.invited_by, None)
     self.assertEqual(
         self.sender.send_notification.call_args_list,
         [
             call('Don\'t try to fool me. Forward message with the link to your friends and '
                 'receive well-earned bonuses that will help you to find partner quickly.'),
             call('*Manual*\n\nUse /begin to start looking for a conversational partner, once '
                 'you\'re matched you can use /end to end the conversation.'),
             ],
         )
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:23,代码来源:test_stranger_handler.py


注:本文中的asynctest.mock.Mock.command_args方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。