Skip to content

Commit

Permalink
Fix bug on prepared request in graph client
Browse files Browse the repository at this point in the history
  • Loading branch information
samwelkanda committed Jul 12, 2021
1 parent 34f4992 commit d125c27
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
12 changes: 11 additions & 1 deletion msgraph/core/_graph_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,17 @@ def _graph_url(self, url: str) -> str:

@attach_context
def prepare_request(self, method, url, **kwargs):
req = Request(method, url, **kwargs)
req = Request(
method,
url,
headers=kwargs.get('headers'),
files=kwargs.get('files'),
data=kwargs.get('data'),
json=kwargs.get('json'),
params=kwargs.get('params'),
cookies=kwargs.get('cookies'),
hooks=kwargs.get('hooks'),
)
prepared = Session().prepare_request(req)
return prepared

Expand Down
16 changes: 16 additions & 0 deletions tests/integration/test_graphclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,19 @@ def test_graph_client_picks_options_from_kwargs():
assert response.status_code == 200
assert 'scopes' in response.request.context.middleware_control.keys()
assert response.request.context.middleware_control['scopes'] == scopes


def test_graph_client_allows_passing_optional_kwargs():
"""
Test the graph client allows passing optional kwargs native to the requests library
such as stream, proxy and cert.
"""
credential = _CustomTokenCredential()
scopes = ['User.Read.All']
client = GraphClient(credential=credential)
response = client.get(
'https://proxy.apisandbox.msdn.microsoft.com/svc?url=https://graph.microsoft.com/v1.0/me',
scopes=scopes,
stream=True
)
assert response.status_code == 200

0 comments on commit d125c27

Please sign in to comment.