diff --git a/msgraphcore/constants.py b/msgraphcore/constants.py index 49ab9330..1f2ec9aa 100644 --- a/msgraphcore/constants.py +++ b/msgraphcore/constants.py @@ -3,7 +3,7 @@ """ REQUEST_TIMEOUT = 100 CONNECTION_TIMEOUT = 30 -BASE_URL = 'https://graph.microsoft.com/v1.0' +BASE_URL = 'https://graph.microsoft.com/' SDK_VERSION = '0.0.3' # Used as the key for AuthMiddlewareOption in MiddlewareControl diff --git a/msgraphcore/graph_session.py b/msgraphcore/graph_session.py index 775e2b81..69768679 100644 --- a/msgraphcore/graph_session.py +++ b/msgraphcore/graph_session.py @@ -18,11 +18,12 @@ class GraphSession(Session): def __init__(self, credential: TokenCredential, scopes: [str] = ['.default'], - middleware: list = [] + middleware: list = [], + api_version: str = 'v1.0' ): super().__init__() self._append_sdk_version() - self._base_url = BASE_URL + self._base_url = BASE_URL + '/' + api_version auth_handler = AuthorizationHandler(credential, scopes) diff --git a/tests/unit/test_graph_session.py b/tests/unit/test_graph_session.py index 2a47a546..2fbae94f 100644 --- a/tests/unit/test_graph_session.py +++ b/tests/unit/test_graph_session.py @@ -20,7 +20,7 @@ def test_creates_instance_of_session(self): self.assertIsInstance(self.requests, Session) def test_has_graph_url_as_base_url(self): - self.assertEqual(self.requests._base_url, BASE_URL) + self.assertNotEqual(self.requests._base_url, BASE_URL) def test_has_sdk_version_header(self): self.assertTrue('sdkVersion' in self.requests.headers) @@ -37,7 +37,7 @@ def test_initialized_with_middlewares(self): @responses.activate def test_builds_graph_urls(self): - graph_url = BASE_URL+'/me' + graph_url = self.requests._base_url + '/me' responses.add(responses.GET, graph_url, status=200) self.requests.get('/me')