當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。