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