Esempio n. 1
0
def test_user_agent():

    with mock.patch.dict('os.environ', {'AZURE_HTTP_USER_AGENT': "mytools"}):
        policy = UserAgentPolicy()
        assert policy.user_agent.endswith("mytools")

        request = ClientRequest('GET', 'http://127.0.0.1/')
        policy.on_request(Request(request))
        assert request.headers["user-agent"].endswith("mytools")
Esempio n. 2
0
 async def do():
     conf = Configuration("http://bing.com/")
     request = ClientRequest("GET", "http://bing.com/")
     policies = [
         UserAgentPolicy("myusergant")
     ]
     async with AsyncPipeline(policies, AsyncPipelineRequestsHTTPSender(AsyncTrioRequestsHTTPSender(conf))) as pipeline:
         return await pipeline.run(request)
Esempio n. 3
0
async def test_basic_async_requests():

    request = ClientRequest("GET", "http://bing.com")
    policies = [
        UserAgentPolicy("myusergant")
    ]
    async with AsyncPipeline(policies, AsyncPipelineRequestsHTTPSender()) as pipeline:
        response = await pipeline.run(request)

    assert response.http_response.status_code == 200
Esempio n. 4
0
async def test_basic_aiohttp():

    request = ClientRequest("GET", "http://bing.com")
    policies = [
        UserAgentPolicy("myusergant")
    ]
    async with AsyncPipeline(policies) as pipeline:
        response = await pipeline.run(request)

    assert pipeline._sender.driver._session.closed
    assert response.http_response.status_code == 200
Esempio n. 5
0
async def test_conf_async_requests():

    conf = Configuration("http://bing.com/")
    request = ClientRequest("GET", "http://bing.com/")
    policies = [
        UserAgentPolicy("myusergant")
    ]
    async with AsyncPipeline(policies, AsyncPipelineRequestsHTTPSender(AsyncRequestsHTTPSender(conf))) as pipeline:
        response = await pipeline.run(request)

    assert response.http_response.status_code == 200