From 61e60b6b387f9da8b860713cdf7d9b7efad76278 Mon Sep 17 00:00:00 2001 From: Tim Hinrichs Date: Fri, 17 Apr 2015 10:52:49 -0700 Subject: [PATCH] Fix bug in "datasource table schema show" Unlike "datasource schema show", the table version required you pass in the ID of the datasource, instead of the name. Change-Id: I07fee067f33f12530bed185d26ed38ef53d76bd3 --- congressclient/osc/v1/datasource.py | 5 ++++- congressclient/tests/v1/test_datasource.py | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/congressclient/osc/v1/datasource.py b/congressclient/osc/v1/datasource.py index 4fe3a71..5c6a76c 100644 --- a/congressclient/osc/v1/datasource.py +++ b/congressclient/osc/v1/datasource.py @@ -149,8 +149,11 @@ class ShowDatasourceTableSchema(lister.Lister): def take_action(self, parsed_args): self.log.debug('take_action(%s)' % parsed_args) client = self.app.client_manager.congressclient + results = client.list_datasources() + datasource_id = utils.get_resource_id_from_name( + parsed_args.datasource_name, results) data = client.show_datasource_table_schema( - parsed_args.datasource_name, + datasource_id, parsed_args.table_name) columns = ['name', 'description'] return (columns, diff --git a/congressclient/tests/v1/test_datasource.py b/congressclient/tests/v1/test_datasource.py index 5a4d321..aca0aa8 100644 --- a/congressclient/tests/v1/test_datasource.py +++ b/congressclient/tests/v1/test_datasource.py @@ -156,9 +156,11 @@ class TestShowDatasourceTableSchema(common.TestCongressBase): cmd = datasource.ShowDatasourceTableSchema(self.app, self.namespace) parsed_args = self.check_parser(cmd, arglist, verifylist) - result = cmd.take_action(parsed_args) + with mock.patch.object(utils, "get_resource_id_from_name", + return_value="id"): + result = cmd.take_action(parsed_args) - lister.assert_called_with(datasource_name, table_name) + lister.assert_called_with("id", table_name) self.assertEqual(['name', 'description'], result[0])