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


Python Mock.text方法代码示例

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


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

示例1: test_handle__other_wizard

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import text [as 别名]
 async def test_handle__other_wizard(self):
     self.stranger.wizard = "other_wizard"
     self.stranger_setup_wizard.activate = CoroutineMock()
     message = Mock()
     message.text = "foo_text"
     self.assertFalse((await self.stranger_setup_wizard.handle(message)))
     self.stranger_setup_wizard.activate.assert_not_called()
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:9,代码来源:test_stranger_setup_wizard.py

示例2: test_handle__deactivated_not_novice

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import text [as 别名]
 async def test_handle__deactivated_not_novice(self):
     self.stranger.wizard = "none"
     self.stranger.is_novice = Mock(return_value=False)
     self.stranger_setup_wizard.activate = CoroutineMock()
     message = Mock()
     message.text = "foo_text"
     self.assertFalse((await self.stranger_setup_wizard.handle(message)))
     self.stranger_setup_wizard.activate.assert_not_called()
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:10,代码来源:test_stranger_setup_wizard.py

示例3: test_handle__sex_ok

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import text [as 别名]
 async def test_handle__sex_ok(self):
     self.stranger.wizard = "setup"
     self.stranger.wizard_step = "sex"
     self.stranger_setup_wizard._prompt = CoroutineMock()
     self.stranger.sex = "some_sex"
     message = Mock()
     message.text = "foo_text"
     self.assertTrue((await self.stranger_setup_wizard.handle(message)))
     self.stranger.set_sex.assert_called_once_with("foo_text")
     self.stranger_setup_wizard._prompt.assert_called_once_with()
     self.assertEqual(self.stranger.wizard_step, "partner_sex")
     self.stranger.save.assert_called_once_with()
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:14,代码来源:test_stranger_setup_wizard.py

示例4: test_handle__unknown_wizard_step

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import text [as 别名]
    async def test_handle__unknown_wizard_step(self):
        from randtalkbot.stranger_setup_wizard import LOGGER

        self.stranger.wizard = "setup"
        self.stranger.wizard_step = "unknown_step"
        self.stranger_setup_wizard._prompt = CoroutineMock()
        message = Mock()
        message.text = "foo_text"
        self.assertTrue((await self.stranger_setup_wizard.handle(message)))
        self.stranger_setup_wizard._prompt.assert_not_called()
        self.sender.send_notification.assert_not_called()
        LOGGER.warning.assert_called_once_with('Undknown wizard_step value was found: "%s"', "unknown_step")
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:14,代码来源:test_stranger_setup_wizard.py

示例5: test_handle__telegram_error

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import text [as 别名]
    async def test_handle__telegram_error(self):
        from randtalkbot.stranger_setup_wizard import LOGGER
        from randtalkbot.stranger_setup_wizard import get_languages_codes

        self.stranger.wizard = "setup"
        self.stranger.wizard_step = "languages"
        get_languages_codes.side_effect = EmptyLanguagesError()
        self.stranger_setup_wizard._prompt = CoroutineMock()
        message = Mock()
        message.text = "foo_text"
        self.sender.send_notification.side_effect = TelegramError({}, "", 0)
        self.assertTrue((await self.stranger_setup_wizard.handle(message)))
        self.assertTrue(LOGGER.warning.called)
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:15,代码来源:test_stranger_setup_wizard.py

示例6: test_handle__sex_not_specified

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import text [as 别名]
 async def test_handle__sex_not_specified(self):
     self.stranger.wizard = "setup"
     self.stranger.wizard_step = "sex"
     self.stranger_setup_wizard._prompt = CoroutineMock()
     self.stranger_setup_wizard.deactivate = CoroutineMock()
     self.stranger.sex = "not_specified"
     message = Mock()
     message.text = "foo_text"
     self.assertTrue((await self.stranger_setup_wizard.handle(message)))
     self.stranger.set_sex.assert_called_once_with("foo_text")
     self.stranger_setup_wizard.deactivate.assert_called_once_with()
     self.stranger_setup_wizard._prompt.assert_not_called()
     self.stranger.save.assert_not_called()
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:15,代码来源:test_stranger_setup_wizard.py

示例7: test_handle__partner_sex_sex_error

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import text [as 别名]
    async def test_handle__partner_sex_sex_error(self):
        from randtalkbot.errors import SexError

        self.stranger.wizard = "setup"
        self.stranger.wizard_step = "partner_sex"
        self.stranger_setup_wizard._prompt = CoroutineMock()
        self.stranger.set_partner_sex.side_effect = SexError("foo_sex")
        message = Mock()
        message.text = "foo_text"
        self.assertTrue((await self.stranger_setup_wizard.handle(message)))
        self.stranger.set_partner_sex.assert_called_once_with("foo_text")
        self.stranger_setup_wizard._prompt.assert_called_once_with()
        self.sender.send_notification.assert_called_once_with(
            'Unknown sex: "{0}" -- is not a valid sex name.', "foo_sex"
        )
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:17,代码来源:test_stranger_setup_wizard.py

示例8: test_handle__languages_language_not_found

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import text [as 别名]
    async def test_handle__languages_language_not_found(self):
        from randtalkbot.stranger_setup_wizard import get_languages_codes
        from randtalkbot.i18n import LanguageNotFoundError

        self.stranger.wizard = "setup"
        self.stranger.wizard_step = "languages"
        get_languages_codes.side_effect = LanguageNotFoundError("foo_lang")
        self.stranger_setup_wizard._prompt = CoroutineMock()
        message = Mock()
        message.text = "foo_text"
        self.assertTrue((await self.stranger_setup_wizard.handle(message)))
        get_languages_codes.assert_called_once_with("foo_text")
        self.stranger.set_languages.assert_not_called()
        self.stranger_setup_wizard._prompt.assert_called_once_with()
        self.sender.send_notification.assert_called_once_with('Language "{0}" wasn\'t found.', "foo_lang")
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:17,代码来源:test_stranger_setup_wizard.py

示例9: test_handle__languages_empty_languages_error

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import text [as 别名]
    async def test_handle__languages_empty_languages_error(self):
        from randtalkbot.stranger_setup_wizard import get_languages_codes
        from randtalkbot.errors import EmptyLanguagesError

        self.stranger.wizard = "setup"
        self.stranger.wizard_step = "languages"
        get_languages_codes.side_effect = EmptyLanguagesError()
        self.stranger_setup_wizard._prompt = CoroutineMock()
        message = Mock()
        message.text = "foo_text"
        self.assertTrue((await self.stranger_setup_wizard.handle(message)))
        get_languages_codes.assert_called_once_with("foo_text")
        self.stranger.set_languages.assert_not_called()
        self.stranger_setup_wizard._prompt.assert_called_once_with()
        self.sender.send_notification.assert_called_once_with("Please specify at least one language.")
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:17,代码来源:test_stranger_setup_wizard.py

示例10: test_handle__languages_ok

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import text [as 别名]
    async def test_handle__languages_ok(self):
        from randtalkbot.stranger_setup_wizard import get_languages_codes

        self.stranger.wizard = "setup"
        self.stranger.wizard_step = "languages"
        get_languages_codes.return_value = "foo_languages_codes"
        self.stranger_setup_wizard._prompt = CoroutineMock()
        message = Mock()
        message.text = "foo_text"
        self.assertTrue((await self.stranger_setup_wizard.handle(message)))
        get_languages_codes.assert_called_once_with("foo_text")
        self.stranger.set_languages.assert_called_once_with("foo_languages_codes")
        self.stranger_setup_wizard._prompt.assert_called_once_with()
        self.assertEqual(self.stranger.wizard_step, "sex")
        self.stranger.save.assert_called_once_with()
        self.sender.update_translation.assert_called_once_with()
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:18,代码来源:test_stranger_setup_wizard.py

示例11: test_handle__languages_too_much

# 需要导入模块: from asynctest.mock import Mock [as 别名]
# 或者: from asynctest.mock.Mock import text [as 别名]
    async def test_handle__languages_too_much(self):
        from randtalkbot.stranger_setup_wizard import get_languages_codes
        from randtalkbot.stranger_setup_wizard import LOGGER
        from randtalkbot.errors import StrangerError

        self.stranger.wizard = "setup"
        self.stranger.wizard_step = "languages"
        get_languages_codes.return_value = "languages_codes"
        self.stranger.set_languages.side_effect = StrangerError()
        self.stranger_setup_wizard._prompt = CoroutineMock()
        message = Mock()
        message.text = "foo_text"
        self.assertTrue((await self.stranger_setup_wizard.handle(message)))
        self.stranger.set_languages.assert_called_once_with("languages_codes")
        self.stranger_setup_wizard._prompt.assert_called_once_with()
        self.sender.send_notification.assert_called_once_with(
            "Too much languages were specified. Please shorten your list to 6 languages."
        )
        LOGGER.info.assert_called_once_with('Too much languages were specified: "%s"', "foo_text")
开发者ID:quasiyoke,项目名称:RandTalkBot,代码行数:21,代码来源:test_stranger_setup_wizard.py


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