async def test_request_mdws_nc_not_copy(): client = http.AsyncClient(tests.fake_url, mdws_nc=[middleware_not_copy]) client._AsyncClient__session = MockSessions(resp={}, code=204, content='') m = tests.Get() resp, status_code = await client.request(m) assert resp == {} assert tests.Get().__dict__ != m.__dict__ assert status_code == 204
async def test_request_get_failure(): client = http.AsyncClient(tests.fake_url) client._AsyncClient__session = MockSessions(resp={}, code=204, content='', failure=True) with pytest.raises(TestException): await client.request(tests.Get())
async def test_request_get_ok(): client = http.AsyncClient(tests.fake_url) client._AsyncClient__session = MockSessions(resp={}, code=204, content='', failure=False) resp, status_code = await client.request(tests.Get()) assert resp == {} assert status_code == 204
async def test_request_mdws_nc(): client = http.Client(tests.fake_url, mdws_nc=[middleware]) client._AsyncClient__session = MockSessions(resp={}, code=204, content='') m = tests.Get() with pytest.raises(AssertionError): client.request(m)
async def test_real_request_global_client(): resp, status_code = await tests.client.request(tests.Get()) assert len(resp) > 1000 assert status_code == 200
async def test_real_request(): client = http.AsyncClient(tests.real_url) resp, status_code = await client.request(tests.Get()) assert len(resp) > 1000 assert status_code == 200