Skip to content

Commit 4428208

Browse files
committed
Force InfluxDBClient to force an integer as the port.
- Includes unit tests - Does not make the change to influxdb08 - Also a small change that was needed to tox.ini that was needed for tox to pass, since setup.py reads README.rst
1 parent 1e8e3dd commit 4428208

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

influxdb/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__(self,
7676
):
7777
"""Construct a new InfluxDBClient object."""
7878
self.__host = host
79-
self.__port = port
79+
self.__port = int(port)
8080
self._username = username
8181
self._password = password
8282
self._database = database

influxdb/tests/client_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,10 @@ def test_revoke_privilege_invalid(self):
794794
with _mocked_session(cli, 'get', 400):
795795
self.cli.revoke_privilege('', 'testdb', 'test')
796796

797+
def test_invalid_port_fails(self):
798+
with self.assertRaises(ValueError):
799+
InfluxDBClient('host', '80/redir', 'username', 'password')
800+
797801

798802
class FakeClient(InfluxDBClient):
799803

influxdb/tests/server_tests/client_test_with_server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ def test_revoke_privilege_invalid(self):
295295
self.assertIn('{"error":"error parsing query: ',
296296
ctx.exception.content)
297297

298+
def test_invalid_port_fails(self):
299+
with self.assertRaises(ValueError):
300+
InfluxDBClient('host', '80/redir', 'username', 'password')
301+
298302

299303
@skipServerTests
300304
class CommonTests(ManyTestCasesWithServerMixin,

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ commands = flake8 influxdb
2020
[testenv:coverage]
2121
deps = -r{toxinidir}/requirements.txt
2222
-r{toxinidir}/test-requirements.txt
23+
-r{toxinidir}/README.rst
2324
pandas
2425
coverage
2526
commands = nosetests -v --with-coverage --cover-html --cover-package=influxdb

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy