From ba67fb2621da9e5b5615ca335ce844feff002b56 Mon Sep 17 00:00:00 2001 From: Masahito Muroi Date: Wed, 8 Apr 2015 05:25:44 +0000 Subject: [PATCH] Use correct URI in show schema for datasource table command This patch changes the command to use datasource id in API request URI. It uses currently datasource name though Congress server expects recieving datasource id in URI. Change-Id: If718d72e2f05672a9774778f3c6935d46e33cd80 Closes-Bug: #1441418 --- 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])