Skip to content

Commit

Permalink
Drop obsolute ssl argument when base_url is given
Browse files Browse the repository at this point in the history
Fixes #652
  • Loading branch information
MariusWirtz committed Dec 17, 2021
1 parent 2d38935 commit d9110aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion TM1py/Services/RestService.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(self, **kwargs):
:param impersonate: Name of user to impersonate
"""
self._kwargs = kwargs
self._ssl = self.translate_to_boolean(kwargs['ssl'])
self._ssl = self.translate_to_boolean(kwargs.get('ssl', True))
self._address = kwargs.get('address', None)
self._port = kwargs.get('port', None)
self._verify = False
Expand Down Expand Up @@ -180,6 +180,7 @@ def __init__(self, **kwargs):

if 'base_url' in kwargs:
self._base_url = kwargs['base_url']
self._ssl = self._determine_ssl_based_on_base_url()
else:
self._base_url = "http{}://{}:{}".format(
's' if self._ssl else '',
Expand Down Expand Up @@ -581,6 +582,14 @@ def wait_time_generator(timeout: int):
while True:
yield 1

def _determine_ssl_based_on_base_url(self) -> bool:
if self._base_url.startswith("https"):
return True
elif self._base_url.startswith("http"):
return False
else:
raise ValueError(f"Invalid base_url: '{self._base_url}'")


class BytesIOSocket:
""" used in urllib3_response_from_bytes method to construct urllib3 response from raw bytes
Expand Down
2 changes: 1 addition & 1 deletion Tests/ElementService_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def test_execute_set_mdx_attribute_with_space(self):
element_properties=None,
parent_properties=None)

self.assertEqual(members, [[{'Name': '1990', 'Attributes': {'Previous Year': '1990'}}]])
self.assertEqual(members, [[{'Name': '1990', 'Attributes': {'Previous Year': '1989'}}]])

@classmethod
def tearDownClass(cls):
Expand Down

0 comments on commit d9110aa

Please sign in to comment.