Skip to content

Commit 5ead1d8

Browse files
committed
Update unit tests
1 parent acc27c3 commit 5ead1d8

File tree

2 files changed

+128
-1
lines changed

2 files changed

+128
-1
lines changed

influxdb/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def delete_database_user(self, username):
518518
# update the user by POSTing to db/site_dev/users/paul
519519

520520
# todo
521-
def update_permission(self, json_body):
521+
def update_permission(self, username, json_body):
522522
"""
523523
Update read/write permission
524524
"""

tests/influxdb/client_test.py

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# -*- coding: utf-8 -*-
2+
"""
3+
unit tests
4+
"""
25
import requests
36
from nose.tools import raises
47
from mock import patch
@@ -25,6 +28,77 @@ def test_switch_user(self):
2528
assert cli._username == 'another_username'
2629
assert cli._password == 'another_password'
2730

31+
def test_write_points(self):
32+
data = [
33+
{
34+
"points": [
35+
["1", 1, 1.0],
36+
["2", 2, 2.0]
37+
],
38+
"name": "foo",
39+
"columns": ["column_one", "column_two", "column_three"]
40+
}
41+
]
42+
43+
with patch.object(requests, 'post') as mocked_post:
44+
mocked_post.return_value = _build_response_object(status_code=200)
45+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
46+
assert cli.write_points(data) is True
47+
48+
@raises(Exception)
49+
def test_write_points_fails(self):
50+
with patch.object(requests, 'post') as mocked_post:
51+
mocked_post.return_value = _build_response_object(status_code=500)
52+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
53+
cli.write_points([])
54+
55+
def test_write_points_with_precision(self):
56+
data = [
57+
{
58+
"points": [
59+
["1", 1, 1.0],
60+
["2", 2, 2.0]
61+
],
62+
"name": "foo",
63+
"columns": ["column_one", "column_two", "column_three"]
64+
}
65+
]
66+
67+
with patch.object(requests, 'post') as mocked_post:
68+
mocked_post.return_value = _build_response_object(status_code=200)
69+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
70+
assert cli.write_points_with_precision(data) is True
71+
72+
@raises(Exception)
73+
def test_write_points_with_precision_fails(self):
74+
with patch.object(requests, 'post') as mocked_post:
75+
mocked_post.return_value = _build_response_object(status_code=500)
76+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
77+
cli.write_points_with_precision([])
78+
79+
@raises(NotImplementedError)
80+
def test_delete_points(self):
81+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
82+
cli.delete_points([])
83+
84+
@raises(NotImplementedError)
85+
def test_create_scheduled_delete(self):
86+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
87+
cli.create_scheduled_delete([])
88+
89+
@raises(NotImplementedError)
90+
def test_get_list_scheduled_delete(self):
91+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
92+
cli.get_list_scheduled_delete()
93+
94+
@raises(NotImplementedError)
95+
def test_remove_scheduled_delete(self):
96+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
97+
cli.remove_scheduled_delete(1)
98+
99+
def test_query(self):
100+
pass
101+
28102
def test_create_database(self):
29103
with patch.object(requests, 'post') as mocked_post:
30104
mocked_post.return_value = _build_response_object(status_code=201)
@@ -51,4 +125,57 @@ def test_delete_database_fails(self):
51125
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
52126
cli.delete_database('old_db')
53127

128+
def test_get_list_cluster_admins(self):
129+
pass
130+
131+
def test_add_cluster_admin(self):
132+
pass
133+
134+
def test_update_cluster_admin_password(self):
135+
pass
136+
137+
def test_delete_cluster_admin(self):
138+
pass
139+
140+
def test_set_database_admin(self):
141+
pass
142+
143+
def test_unset_database_admin(self):
144+
pass
145+
146+
@raises(NotImplementedError)
147+
def test_get_list_database_admins(self):
148+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
149+
cli.get_list_database_admins()
150+
151+
@raises(NotImplementedError)
152+
def test_add_database_admin(self):
153+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
154+
cli.add_database_admin('admin', 'admin_secret_password')
155+
156+
@raises(NotImplementedError)
157+
def test_update_database_admin_password(self):
158+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
159+
cli.update_database_admin_password('admin', 'admin_secret_password')
160+
161+
@raises(NotImplementedError)
162+
def test_delete_database_admin(self):
163+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
164+
cli.delete_database_admin('admin')
165+
166+
def test_get_database_user(self):
167+
pass
168+
169+
def test_add_database_user(self):
170+
pass
171+
172+
def test_update_database_user_password(self):
173+
pass
174+
175+
def test_delete_database_user(self):
176+
pass
54177

178+
@raises(NotImplementedError)
179+
def test_update_permission(self):
180+
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
181+
cli.update_permission('admin', [])

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