-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
Here's the full log:
=================================== FAILURES ===================================
______________________ TestServiceClient.test_client_send ______________________
self = <test_async_client.TestServiceClient object at 0x7ffff451a850>
@pytest.mark.asyncio
async def test_client_send(self):
cfg = Configuration("/")
cfg.headers = {'Test': 'true'}
cfg.credentials = mock.create_autospec(OAuthTokenAuthentication)
client = ServiceClientAsync(cfg)
req_response = requests.Response()
req_response._content = br'{"real": true}' # Has to be valid bytes JSON
req_response._content_consumed = True
req_response.status_code = 200
def side_effect(*args, **kwargs):
return req_response
session = mock.create_autospec(requests.Session)
session.request.side_effect = side_effect
session.adapters = {
"http://": HTTPAdapter(),
"https://": HTTPAdapter(),
}
# Be sure the mock does not trick me
assert not hasattr(session.resolve_redirects, 'is_msrest_patched')
client.config.pipeline._sender.driver.session = session
client.config.credentials.signed_session.return_value = session
client.config.credentials.refresh_session.return_value = session
request = ClientRequest('GET', '/')
await client.async_send(request, stream=False)
session.request.call_count = 0
session.request.assert_called_with(
'GET',
'/',
allow_redirects=True,
cert=None,
headers={
'User-Agent': cfg.user_agent,
'Test': 'true' # From global config
},
stream=False,
timeout=100,
verify=True
)
assert session.resolve_redirects.is_msrest_patched
request = client.get('/', headers={'id':'1234'}, content={'Test':'Data'})
await client.async_send(request, stream=False)
session.request.assert_called_with(
'GET',
'/',
data='{"Test": "Data"}',
allow_redirects=True,
cert=None,
headers={
'User-Agent': cfg.user_agent,
'Content-Length': '16',
'id':'1234',
'Accept': 'application/json',
'Test': 'true' # From global config
},
stream=False,
timeout=100,
verify=True
)
> assert session.request.call_count == 1
E AssertionError: assert 2 == 1
E + where 2 = <MagicMock name='mock.signed_session().request' spec='function' id='140737289512544'>.call_count
E + where <MagicMock name='mock.signed_session().request' spec='function' id='140737289512544'> = <MagicMock name='mock.signed_session()' spec='Session' id='140737291051296'>.request
tests/asynctests/test_async_client.py:123: AssertionError
______________________ TestServiceClient.test_client_send ______________________
self = <tests.test_client.TestServiceClient testMethod=test_client_send>
def test_client_send(self):
current_ua = self.cfg.user_agent
client = ServiceClient(self.creds, self.cfg)
client.config.keep_alive = True
req_response = requests.Response()
req_response._content = br'{"real": true}' # Has to be valid bytes JSON
req_response._content_consumed = True
req_response.status_code = 200
def side_effect(*args, **kwargs):
return req_response
session = mock.create_autospec(requests.Session)
session.request.side_effect = side_effect
session.adapters = {
"http://": HTTPAdapter(),
"https://": HTTPAdapter(),
}
# Be sure the mock does not trick me
assert not hasattr(session.resolve_redirects, 'is_msrest_patched')
client.config.pipeline._sender.driver.session = session
client.config.credentials.signed_session.return_value = session
client.config.credentials.refresh_session.return_value = session
request = ClientRequest('GET', '/')
client.send(request, stream=False)
session.request.call_count = 0
session.request.assert_called_with(
'GET',
'/',
allow_redirects=True,
cert=None,
headers={
'User-Agent': current_ua,
'Test': 'true' # From global config
},
stream=False,
timeout=100,
verify=True
)
assert session.resolve_redirects.is_msrest_patched
client.send(request, headers={'id':'1234'}, content={'Test':'Data'}, stream=False)
session.request.assert_called_with(
'GET',
'/',
data='{"Test": "Data"}',
allow_redirects=True,
cert=None,
headers={
'User-Agent': current_ua,
'Content-Length': '16',
'id':'1234',
'Test': 'true' # From global config
},
stream=False,
timeout=100,
verify=True
)
> self.assertEqual(session.request.call_count, 1)
E AssertionError: 2 != 1
tests/test_client.py:329: AssertionError
=============================== warnings summary ===============================
tests/test_client.py::TestServiceClient::test_client_request
tests/test_client.py::TestServiceClient::test_deprecated_creds
tests/test_runtime.py::TestRuntimeRetry::test_request_retry_3_times
tests/test_runtime.py::TestRuntimeRetry::test_request_retry_404
tests/test_runtime.py::TestRuntimeRetry::test_request_retry_408
tests/test_runtime.py::TestRuntimeRetry::test_request_retry_501
tests/test_runtime.py::TestRuntimeRetry::test_request_retry_502
tests/test_runtime.py::TestRuntimeRetry::test_request_retry_505
tests/test_runtime.py::TestRuntimeRetry::test_request_retry_max
/build/source/msrest/service_client.py:259: DeprecationWarning: Creds parameter is deprecated. Set config.credentials instead.
warnings.warn("Creds parameter is deprecated. Set config.credentials instead.",
tests/test_runtime.py: 31 warnings
/nix/store/g7jsn1ilpq388gh269cj4jjmx4175na1-python3.13-httpretty-1.1.4/lib/python3.13/site-packages/httpretty/core.py:1080: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
now = datetime.utcnow()
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================= slowest 10 durations =============================
2.00s call tests/asynctests/test_polling.py::test_poller
1.00s call tests/test_polling.py::test_poller
0.04s call tests/asynctests/test_async_client.py::TestServiceClient::test_client_send
0.03s call tests/test_client.py::TestServiceClient::test_client_send
0.03s call tests/test_client.py::TestServiceClient::test_format_url
0.01s call tests/test_client.py::TestServiceClient::test_context_manager
0.01s call tests/test_client.py::TestServiceClient::test_keep_alive
0.01s call tests/test_client.py::TestServiceClient::test_sdk_context_manager
0.01s call tests/test_client.py::TestServiceClient::test_deprecated_creds
0.01s call tests/test_client.py::TestServiceClient::test_client_request
=========================== short test summary info ============================
FAILED tests/asynctests/test_async_client.py::TestServiceClient::test_client_send - AssertionError: assert 2 == 1
FAILED tests/test_client.py::TestServiceClient::test_client_send - AssertionError: 2 != 1
========== 2 failed, 196 passed, 12 deselected, 40 warnings in 4.12s ===========We experience this on Nixpkgs.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels