Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Force InfluxDBClient to force an integer as the port.
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
canardleteer committed Feb 28, 2016
1 parent 1e8e3dd commit 4428208
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion influxdb/client.py
Expand Up @@ -76,7 +76,7 @@ def __init__(self,
):
"""Construct a new InfluxDBClient object."""
self.__host = host
self.__port = port
self.__port = int(port)
self._username = username
self._password = password
self._database = database
Expand Down
4 changes: 4 additions & 0 deletions influxdb/tests/client_test.py
Expand Up @@ -794,6 +794,10 @@ def test_revoke_privilege_invalid(self):
with _mocked_session(cli, 'get', 400):
self.cli.revoke_privilege('', 'testdb', 'test')

def test_invalid_port_fails(self):
with self.assertRaises(ValueError):
InfluxDBClient('host', '80/redir', 'username', 'password')


class FakeClient(InfluxDBClient):

Expand Down
4 changes: 4 additions & 0 deletions influxdb/tests/server_tests/client_test_with_server.py
Expand Up @@ -295,6 +295,10 @@ def test_revoke_privilege_invalid(self):
self.assertIn('{"error":"error parsing query: ',
ctx.exception.content)

def test_invalid_port_fails(self):
with self.assertRaises(ValueError):
InfluxDBClient('host', '80/redir', 'username', 'password')


@skipServerTests
class CommonTests(ManyTestCasesWithServerMixin,
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Expand Up @@ -20,6 +20,7 @@ commands = flake8 influxdb
[testenv:coverage]
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/README.rst
pandas
coverage
commands = nosetests -v --with-coverage --cover-html --cover-package=influxdb
Expand Down

0 comments on commit 4428208

Please sign in to comment.