Skip to content

Test and fix for None path #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion influxdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def __init__(self,
"""Construct a new InfluxDBClient object."""
self.__host = host
self.__port = int(port)
self.__path = path if not path or path[0] == '/' else '/' + path
self._username = username
self._password = password
self._database = database
Expand All @@ -102,6 +101,13 @@ def __init__(self,
if use_udp:
self.udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

if not path:
self.__path = ''
elif path[0] == '/':
self.__path = path
else:
self.__path = '/' + path

self._scheme = "http"

if ssl is True:
Expand Down
6 changes: 6 additions & 0 deletions influxdb/tests/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ def test_scheme(self):
)
self.assertEqual('https://host:8086/somepath', cli._baseurl)

cli = InfluxDBClient(
'host', 8086, 'username', 'password', 'database', ssl=True,
path=None
)
self.assertEqual('https://host:8086', cli._baseurl)

cli = InfluxDBClient(
'host', 8086, 'username', 'password', 'database', ssl=True,
path="/somepath"
Expand Down