Skip to content

Commit beecccc

Browse files
author
aviau
committed
Fixed flake8 + added test for permissions
1 parent 5d2bffc commit beecccc

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

influxdb/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,9 @@ def add_database_user(self, new_username, new_password, permissions=None):
624624
try:
625625
data['readFrom'], data['writeTo'] = permissions
626626
except (ValueError, TypeError):
627-
raise TypeError("'permissions' must be (readFrom, writeTo) tuple")
627+
raise TypeError(
628+
"'permissions' must be (readFrom, writeTo) tuple"
629+
)
628630

629631
self.request(
630632
url=url,

tests/influxdb/client_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,21 @@ def test_get_database_user(self):
326326
def test_add_database_user(self):
327327
pass
328328

329+
def test_add_database_user_bad_permissions(self):
330+
cli = InfluxDBClient()
331+
332+
with self.assertRaises(Exception) as ex:
333+
cli.add_database_user(
334+
new_password='paul',
335+
new_username='paul',
336+
permissions=('hello', 'hello', 'hello')
337+
)
338+
339+
self.assertEqual(
340+
str(ex.exception),
341+
"'permissions' must be (readFrom, writeTo) tuple"
342+
)
343+
329344
def test_update_database_user_password(self):
330345
pass
331346

0 commit comments

Comments
 (0)