@@ -43,15 +43,15 @@ def request(*args, **kwargs):
43
43
44
44
# Anyway, Content must be a JSON string (or empty string)
45
45
if not isinstance (c , str ):
46
- c = json .dumps (c )
46
+ c = json .dumps (c )
47
47
48
48
return _build_response_object (status_code = status_code , content = c )
49
49
50
50
mocked = patch .object (
51
51
session ,
52
52
'request' ,
53
- side_effect = request
54
- )
53
+ side_effect = request
54
+ )
55
55
56
56
return mocked
57
57
@@ -88,7 +88,7 @@ def test_write_points(self):
88
88
}
89
89
]
90
90
91
- with _mocked_session ('post' , 200 , data ) as mocked :
91
+ with _mocked_session ('post' , 200 , data ):
92
92
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
93
93
assert cli .write_points (data ) is True
94
94
@@ -115,7 +115,7 @@ def test_write_points_udp(self):
115
115
116
116
@raises (Exception )
117
117
def test_write_points_fails (self ):
118
- with _mocked_session ('post' , 500 ) as mocked :
118
+ with _mocked_session ('post' , 500 ):
119
119
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
120
120
cli .write_points ([])
121
121
@@ -131,13 +131,13 @@ def test_write_points_with_precision(self):
131
131
}
132
132
]
133
133
134
- with _mocked_session ('post' , 200 , data ) as mocked :
134
+ with _mocked_session ('post' , 200 , data ):
135
135
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
136
136
assert cli .write_points_with_precision (data ) is True
137
137
138
138
@raises (Exception )
139
139
def test_write_points_with_precision_fails (self ):
140
- with _mocked_session ('post' , 500 ) as mocked :
140
+ with _mocked_session ('post' , 500 ):
141
141
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
142
142
cli .write_points_with_precision ([])
143
143
@@ -154,7 +154,7 @@ def test_delete_points(self):
154
154
155
155
@raises (Exception )
156
156
def test_delete_points_with_wrong_name (self ):
157
- with _mocked_session ('delete' , 400 ) as mocked :
157
+ with _mocked_session ('delete' , 400 ):
158
158
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
159
159
cli .delete_points ("nonexist" )
160
160
@@ -175,70 +175,71 @@ def test_remove_scheduled_delete(self):
175
175
176
176
def test_query (self ):
177
177
data = [
178
- { "name" :"foo" ,
178
+ {
179
+ "name" : "foo" ,
179
180
"columns" : ["time" , "sequence_number" , "column_one" ],
180
181
"points" : [
181
182
[1383876043 , 16 , "2" ], [1383876043 , 15 , "1" ],
182
183
[1383876035 , 14 , "2" ], [1383876035 , 13 , "1" ]
183
184
]
184
185
}
185
186
]
186
- with _mocked_session ('get' , 200 , data ) as mocked :
187
+ with _mocked_session ('get' , 200 , data ):
187
188
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
188
189
result = cli .query ('select column_one from foo;' )
189
190
assert len (result [0 ]['points' ]) == 4
190
191
191
192
@raises (Exception )
192
193
def test_query_fail (self ):
193
- with _mocked_session ('get' , 401 ) as mocked :
194
+ with _mocked_session ('get' , 401 ):
194
195
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
195
196
cli .query ('select column_one from foo;' )
196
197
197
198
def test_create_database (self ):
198
- with _mocked_session ('post' , 201 , {"name" : "new_db" }) as mocked :
199
+ with _mocked_session ('post' , 201 , {"name" : "new_db" }):
199
200
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
200
201
assert cli .create_database ('new_db' ) is True
201
202
202
203
@raises (Exception )
203
204
def test_create_database_fails (self ):
204
- with _mocked_session ('post' , 401 ) as mocked :
205
+ with _mocked_session ('post' , 401 ):
205
206
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
206
207
cli .create_database ('new_db' )
207
208
208
209
def test_delete_database (self ):
209
- with _mocked_session ('delete' , 204 ) as mocked :
210
+ with _mocked_session ('delete' , 204 ):
210
211
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
211
212
assert cli .delete_database ('old_db' ) is True
212
213
213
214
@raises (Exception )
214
215
def test_delete_database_fails (self ):
215
- with _mocked_session ('delete' , 401 ) as mocked :
216
+ with _mocked_session ('delete' , 401 ):
216
217
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
217
218
cli .delete_database ('old_db' )
218
219
219
220
def test_get_database_list (self ):
220
221
data = [
221
222
{"name" : "a_db" }
222
223
]
223
- with _mocked_session ('get' , 200 , data ) as mocked :
224
+ with _mocked_session ('get' , 200 , data ):
224
225
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' )
225
226
assert len (cli .get_database_list ()) == 1
226
227
assert cli .get_database_list ()[0 ]['name' ] == 'a_db'
227
228
228
229
@raises (Exception )
229
230
def test_get_database_list_fails (self ):
230
- with _mocked_session ('get' , 401 ) as mocked :
231
+ with _mocked_session ('get' , 401 ):
231
232
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' )
232
233
cli .get_database_list ()
233
234
234
235
def test_delete_series (self ):
235
- with _mocked_session ('delete' , 204 ) as mocked :
236
+ with _mocked_session ('delete' , 204 ):
236
237
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
237
238
cli .delete_series ('old_series' )
238
239
239
240
@raises (Exception )
240
241
def test_delete_series_fails (self ):
241
- with _mocked_session ('delete' , 401 ) as mocked :
242
+ with _mocked_session ('delete' , 401 ):
242
243
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
243
244
cli .delete_series ('old_series' )
244
245
@@ -295,4 +296,4 @@ def test_delete_database_user(self):
295
296
@raises (NotImplementedError )
296
297
def test_update_permission (self ):
297
298
cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' , 'db' )
298
- cli .update_permission ('admin' , [])
299
+ cli .update_permission ('admin' , [])
0 commit comments