Skip to content

Commit 4ab46dc

Browse files
Update sdkVersion in graph_session.py
Fixes #42 Prepended sdkVersion with comma separated new values in self.headers in graph_session.py Modified a test and added another test to check whether the value has been updated correctly
1 parent 14fe407 commit 4ab46dc

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

msgraphcore/graph_session.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ class GraphSession(Session):
2020
"""
2121
def __init__(self, auth_provider: AuthProviderBase, middleware: list = []):
2222
super().__init__()
23-
self.headers.update({'sdkVersion': 'graph-python-' + SDK_VERSION})
23+
if 'sdkVersion' not in self.headers:
24+
self.headers.update({'sdkVersion': 'graph-python-' + SDK_VERSION})
25+
else:
26+
self.headers.update({'sdkVersion': 'graph-python-' + SDK_VERSION + ', '
27+
+ self.headers.get('sdkVersion')})
2428
self._base_url = BASE_URL
2529

2630
auth_handler = AuthorizationHandler(auth_provider)

tests/unit/test_graph_session.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ def test_has_graph_url_as_base_url(self):
2424
self.assertEqual(self.requests._base_url, BASE_URL)
2525

2626
def test_has_sdk_version_header(self):
27-
self.assertEqual(self.requests.headers.get('sdkVersion'), 'graph-python-'+SDK_VERSION)
27+
self.assertTrue('sdkVersion' in self.requests.headers)
28+
29+
def test_updated_sdk_version(self):
30+
self.assertTrue(self.requests.headers.get('sdkVersion')
31+
.startswith('graph-python-'+SDK_VERSION))
2832

2933
def test_initialized_with_middlewares(self):
3034
graph_session = GraphSession(self.auth_provider)

0 commit comments

Comments
 (0)