Ejemplo n.º 1
0
def test_imap_not_fully_enabled(monkeypatch):

    def folder_list_fail(conn):
        raise Exception("LIST failed: '[ALERT] full IMAP support "
                        "is NOT enabled for this account'")

    monkeypatch.setattr('imapclient.IMAPClient.list_folders',
                        folder_list_fail)

    def fake_connect(account):
        return MockIMAPClient()

    response = {
        'email': '*****@*****.**',
        'password': '******',
        'imap_server_host': '0.0.0.0',
        'imap_server_port': 22,
        'smtp_server_host': '0.0.0.0',
        'smtp_server_port': 23
    }

    handler = GenericAuthHandler('custom')
    acct = handler.create_account(
        '*****@*****.**',
        response)
    handler.connect_account = fake_connect
    handler._supports_condstore = lambda x: True
    with pytest.raises(UserRecoverableConfigError):
        verified = handler.verify_account(acct)
        assert verified is not True