diff --git a/ringcentral/http/client.py b/ringcentral/http/client.py index ef48c46..bbd1ebc 100644 --- a/ringcentral/http/client.py +++ b/ringcentral/http/client.py @@ -75,8 +75,7 @@ def create_request(self, method='', url='', query_params=None, body=None, header url = url + ('&' if url.find('?') > 0 else '?') + query content_type = None - accept = None - + if headers is None: headers = {} @@ -86,16 +85,12 @@ def create_request(self, method='', url='', query_params=None, body=None, header if key.lower().find('content-type') >= 0: content_type = value if key.lower().find('accept') >= 0: - accept = value + headers['Accept'] = value if content_type is None: content_type = 'application/json' headers['Content-Type'] = content_type - if accept is None: - accept = 'application/json' - headers['Accept'] = accept - if content_type.lower().find('application/json') >= 0: body = json.dumps(body) if body else None elif content_type.lower().find('application/x-www-form-urlencoded') >= 0: diff --git a/ringcentral/platform/platform_test.py b/ringcentral/platform/platform_test.py index d1165a9..6f8f4a7 100644 --- a/ringcentral/platform/platform_test.py +++ b/ringcentral/platform/platform_test.py @@ -26,9 +26,9 @@ def test_login_code(self, mock): sdk.platform().login(code='foo') text = str(mock.request_history[-1].text) if sys.version_info[0] == 3: - self.assertEqual(text, 'grant_type=authorization_code&redirect_uri=mock%3A%2F%2Fwhatever-redirect&code=foo') + self.assertEqual(text, 'grant_type=authorization_code&redirect_uri=https%3A%2F%2Fwhatever-redirect&code=foo') else: - self.assertEqual(text, 'code=foo&grant_type=authorization_code&redirect_uri=mock%3A%2F%2Fwhatever-redirect') + self.assertEqual(text, 'code=foo&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fwhatever-redirect') def test_login_fail(self, mock): sdk = self.get_sdk(mock) @@ -123,7 +123,7 @@ def test_logout(self, mock): def test_api_url(self, mock): sdk = self.get_sdk(mock) - exp1 = 'mock://whatever/restapi/v1.0/account/~/extension/~?_method=POST&access_token=ACCESS_TOKEN' + exp1 = 'https://whatever/restapi/v1.0/account/~/extension/~?_method=POST&access_token=ACCESS_TOKEN' act1 = sdk.platform().create_url('/account/~/extension/~', add_server=True, add_method='POST', add_token=True) self.assertEqual(exp1, act1) @@ -134,12 +134,12 @@ def test_api_url(self, mock): def test_api_url_custom_prefixes(self, mock): sdk = self.get_sdk(mock) - exp = 'mock://whatever/scim/v2/foo' + exp = 'https://whatever/scim/v2/foo' url = '/scim/v2/foo' act = sdk.platform().create_url(url, add_server=True) self.assertEqual(exp, act) - exp = 'mock://whatever/analytics/phone/foo' + exp = 'https://whatever/analytics/phone/foo' url = '/analytics/phone/foo' act = sdk.platform().create_url(url, add_server=True) self.assertEqual(exp, act) diff --git a/ringcentral/sdk_test.py b/ringcentral/sdk_test.py index 67ae2eb..0df1fa0 100644 --- a/ringcentral/sdk_test.py +++ b/ringcentral/sdk_test.py @@ -8,8 +8,8 @@ class TestSDK(TestCase): def test_instance(self): - sdk = SDK('whatever', 'whatever', 'mock://whatever') - self.assertEqual(sdk.platform().create_url('/foo', add_server=True), 'mock://whatever/restapi/v1.0/foo') + sdk = SDK('whatever', 'whatever', 'https://whatever') + self.assertEqual(sdk.platform().create_url('/foo', add_server=True), 'https://whatever/restapi/v1.0/foo') if __name__ == '__main__': diff --git a/ringcentral/test/testcase.py b/ringcentral/test/testcase.py index f5766ed..e49f04e 100644 --- a/ringcentral/test/testcase.py +++ b/ringcentral/test/testcase.py @@ -18,7 +18,7 @@ def __init__(self, method_name=None): def get_sdk(self, mock): - sdk = SDK('whatever', 'whatever', 'mock://whatever', redirect_uri='mock://whatever-redirect') + sdk = SDK('whatever', 'whatever', 'https://whatever', redirect_uri='https://whatever-redirect') self.authentication_mock(mock) sdk.platform().login('18881112233', None, 'password') @@ -44,7 +44,7 @@ def get_sdk(self, mock): def add(self, mock, method, url, body, status=200): mock.register_uri( method=method, - url='mock://whatever' + url, + url='https://whatever' + url, text=json.dumps(body), headers={'Content-Type': 'application/json'}, status_code=status