From e6087e47893f1bf604785d484807e1e1215f7b57 Mon Sep 17 00:00:00 2001 From: user9 Date: Sun, 14 Jun 2020 12:00:22 -0400 Subject: [PATCH 1/2] make api version configurable to support beta api --- msgraphcore/constants.py | 2 +- msgraphcore/graph_session.py | 5 +++-- tests/unit/test_graph_session.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) 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..27baa512 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 = '1.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') From a0a928de1d81e38c65bfa5fdc92eecbad3e03df7 Mon Sep 17 00:00:00 2001 From: user9 Date: Mon, 15 Jun 2020 20:09:36 -0400 Subject: [PATCH 2/2] address MIchaelMainer request --- msgraphcore/graph_session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msgraphcore/graph_session.py b/msgraphcore/graph_session.py index 27baa512..69768679 100644 --- a/msgraphcore/graph_session.py +++ b/msgraphcore/graph_session.py @@ -19,7 +19,7 @@ def __init__(self, credential: TokenCredential, scopes: [str] = ['.default'], middleware: list = [], - api_version: str = '1.0' + api_version: str = 'v1.0' ): super().__init__() self._append_sdk_version()