Skip to content

Commit e6087e4

Browse files
author
user9
committed
make api version configurable to support beta api
1 parent d49ea04 commit e6087e4

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

msgraphcore/constants.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
REQUEST_TIMEOUT = 100
55
CONNECTION_TIMEOUT = 30
6-
BASE_URL = 'https://graph.microsoft.com/v1.0'
6+
BASE_URL = 'https://graph.microsoft.com/'
77
SDK_VERSION = '0.0.3'
88

99
# Used as the key for AuthMiddlewareOption in MiddlewareControl

msgraphcore/graph_session.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ class GraphSession(Session):
1818
def __init__(self,
1919
credential: TokenCredential,
2020
scopes: [str] = ['.default'],
21-
middleware: list = []
21+
middleware: list = [],
22+
api_version: str = '1.0'
2223
):
2324
super().__init__()
2425
self._append_sdk_version()
25-
self._base_url = BASE_URL
26+
self._base_url = BASE_URL + '/' + api_version
2627

2728
auth_handler = AuthorizationHandler(credential, scopes)
2829

tests/unit/test_graph_session.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_creates_instance_of_session(self):
2020
self.assertIsInstance(self.requests, Session)
2121

2222
def test_has_graph_url_as_base_url(self):
23-
self.assertEqual(self.requests._base_url, BASE_URL)
23+
self.assertNotEqual(self.requests._base_url, BASE_URL)
2424

2525
def test_has_sdk_version_header(self):
2626
self.assertTrue('sdkVersion' in self.requests.headers)
@@ -37,7 +37,7 @@ def test_initialized_with_middlewares(self):
3737

3838
@responses.activate
3939
def test_builds_graph_urls(self):
40-
graph_url = BASE_URL+'/me'
40+
graph_url = self.requests._base_url + '/me'
4141
responses.add(responses.GET, graph_url, status=200)
4242

4343
self.requests.get('/me')

0 commit comments

Comments
 (0)