Skip to content

Commit b231c79

Browse files
author
aviau
committed
get_database_list -> get_list_database
1 parent 67fca3d commit b231c79

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

influxdb/client.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def delete_database(self, database):
402402
# ### get list of databases
403403
# curl -X GET http://localhost:8086/db
404404

405-
def get_database_list(self):
405+
def get_list_database(self):
406406
"""
407407
Get the list of databases
408408
"""
@@ -416,6 +416,18 @@ def get_database_list(self):
416416

417417
return response.json()
418418

419+
def get_database_list(self):
420+
"""
421+
DEPRECATED. Get the list of databases
422+
423+
"""
424+
warnings.warn(
425+
"get_database_list is deprecated, and will be removed "
426+
"in future versions. Please use "
427+
"``InfluxDBClient.get_list_database`` instead.",
428+
FutureWarning)
429+
return self.get_list_database()
430+
419431
def delete_series(self, series):
420432
"""
421433
delete_series()

tests/influxdb/client_test.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import requests_mock
1010
from nose.tools import raises
1111
from mock import patch
12+
import warnings
1213

1314
from influxdb import InfluxDBClient
1415
from influxdb.client import session
@@ -61,6 +62,9 @@ def request(*args, **kwargs):
6162
class TestInfluxDBClient(unittest.TestCase):
6263

6364
def setUp(self):
65+
# By default, ignore warnings
66+
warnings.simplefilter('ignore', FutureWarning)
67+
6468
self.dummy_points = [
6569
{
6670
"points": [
@@ -308,20 +312,31 @@ def test_delete_database_fails(self):
308312
cli = InfluxDBClient('host', 8086, 'username', 'password', 'db')
309313
cli.delete_database('old_db')
310314

311-
def test_get_database_list(self):
315+
def test_get_list_database(self):
312316
data = [
313317
{"name": "a_db"}
314318
]
315319
with _mocked_session('get', 200, data):
316320
cli = InfluxDBClient('host', 8086, 'username', 'password')
317321
assert len(cli.get_database_list()) == 1
318-
assert cli.get_database_list()[0]['name'] == 'a_db'
322+
assert cli.get_list_database()[0]['name'] == 'a_db'
319323

320324
@raises(Exception)
321-
def test_get_database_list_fails(self):
325+
def test_get_list_database_fails(self):
322326
with _mocked_session('get', 401):
323327
cli = InfluxDBClient('host', 8086, 'username', 'password')
324-
cli.get_database_list()
328+
cli.get_list_database()
329+
330+
@raises(FutureWarning)
331+
def test_get_database_list_deprecated(self):
332+
warnings.simplefilter('error', FutureWarning)
333+
data = [
334+
{"name": "a_db"}
335+
]
336+
with _mocked_session('get', 200, data):
337+
cli = InfluxDBClient('host', 8086, 'username', 'password')
338+
assert len(cli.get_database_list()) == 1
339+
assert cli.get_database_list()[0]['name'] == 'a_db'
325340

326341
def test_delete_series(self):
327342
with _mocked_session('delete', 204):

0 commit comments

Comments
 (0)