コード例 #1
0
def test_sync_bot_token_obtaining_with_errored_request(hostname, bot_id,
                                                       sync_error_requests):
    bot = Bot()
    cts = CTS(host=hostname, secret_key="secret")
    bot.register_cts(cts)

    bot._obtain_token(hostname, bot_id)
    assert bot._credentials.known_cts[cts.host][1] is None
コード例 #2
0
def test_sync_bot_token_obtaining(hostname, bot_id, sync_requests):
    bot = Bot()

    with pytest.raises(BotXException):
        bot._obtain_token(hostname, bot_id)

    cts = CTS(host=hostname, secret_key="secret")

    bot.register_cts(cts)
    bot._obtain_token(hostname, bot_id)
    assert bot._credentials.known_cts[cts.host] == (
        cts,
        CTSCredentials(bot_id=bot_id, result="token_for_operations"),
    )
コード例 #3
0
def test_sync_bot_work_with_disabled_credentials(sync_requests,
                                                 command_with_text_and_file):
    bot = Bot(disable_credentials=True)

    def token_obtaining_mock(**data):
        raise Exception()

    bot._obtain_token = token_obtaining_mock

    m = Message(**command_with_text_and_file)
    bot.send_message(m.body, m.sync_id, m.bot_id, m.host)