From 461dd9c7b5434aea29e531088e3870bd20775aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Starck?= Date: Mon, 30 Mar 2015 10:31:04 -0400 Subject: [PATCH 1/2] Fix for last server update (v0.9.0-rc17-1-g947c776) "SHOW DATABASES" now returns the databases list in the 'databases' dict key of the response. --- influxdb/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/influxdb/client.py b/influxdb/client.py index 3ddd794d..8b4d7a43 100755 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -295,7 +295,8 @@ def get_list_database(self): """ Get the list of databases """ - return [db['name'] for db in self.query("SHOW DATABASES")] + rsp = self.query("SHOW DATABASES") + return [db['name'] for db in rsp['databases']] def create_database(self, dbname): """ From 2a4f8fedca20de71fc0fa9b720f3fdfdfbef4c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Starck?= Date: Mon, 30 Mar 2015 10:37:22 -0400 Subject: [PATCH 2/2] Also adapt mock data for "fake" client test --- tests/influxdb/client_test.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/influxdb/client_test.py b/tests/influxdb/client_test.py index 3f0a08fb..01550b9c 100644 --- a/tests/influxdb/client_test.py +++ b/tests/influxdb/client_test.py @@ -350,14 +350,9 @@ def test_drop_database_fails(self): cli.drop_database('old_db') def test_get_list_database(self): - data = { - "results": - [ - {"series": [ - {"columns": ["name"], - "values":[["mydb"], ["myotherdb"]]}]} - ] - } + data = {'results': [{'series': [ + {'name': 'databases', 'columns': ['name'], + 'values': [['mydb'], ['myotherdb']]}]}]} with _mocked_session('get', 200, json.dumps(data)): self.assertListEqual(