from settings import settings

from office365.runtime.auth.client_credential import ClientCredential
from office365.sharepoint.client_context import ClientContext


def set_proxy(request):
    proxies = {settings['url']: 'https://127.0.0.1:8888'}
    request.proxies = proxies


ctx = ClientContext(settings['url']).with_credentials(ClientCredential(settings['client_credentials']['client_id'],
                                                                       settings['client_credentials']['client_secret']))

ctx.pending_request().beforeExecute += set_proxy

target_web = ctx.web
ctx.load(target_web)
ctx.execute_query()
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.webs.web import Web
from tests import test_site_url, test_client_credentials

ctx = ClientContext(test_site_url).with_credentials(test_client_credentials)


def disable_ssl(request):
    request.verify = False  # Disable certification verification


ctx.pending_request().beforeExecute += disable_ssl

web = ctx.web.get().execute_query()  # type: Web
print(web.url)