1
1
# -*- coding: utf-8 -*-
2
+ """
3
+ unit tests
4
+ """
2
5
import requests
3
6
from nose .tools import raises
4
7
from mock import patch
@@ -25,6 +28,77 @@ def test_switch_user(self):
25
28
assert cli ._username == 'another_username'
26
29
assert cli ._password == 'another_password'
27
30
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
+
28
102
def test_create_database (self ):
29
103
with patch .object (requests , 'post' ) as mocked_post :
30
104
mocked_post .return_value = _build_response_object (status_code = 201 )
@@ -51,4 +125,57 @@ def test_delete_database_fails(self):
51
125
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
52
126
cli .delete_database ('old_db' )
53
127
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
54
177
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