summaryrefslogtreecommitdiff
path: root/openstackclient/network
diff options
context:
space:
mode:
authorTang Chen <chen.tang@easystack.cn>2016-03-03 20:50:17 +0800
committerTang Chen <chen.tang@easystack.cn>2016-03-03 20:50:17 +0800
commit50443127c56e4de94bdd141ce22900d63736fbea (patch)
treee86a272377eee09f04f50edb21346d3a29652853 /openstackclient/network
parent4ab66631d016cf1e01d7825c8eae678bf9f778ca (diff)
downloadpython-openstackclient-50443127c56e4de94bdd141ce22900d63736fbea.tar.gz
Fix incorrect unit test for router
Command "router show" will display router's "tenant_id" as "project_id". But in the unit test, it checks "tenant_id", which is incorrect. This patch fix this problem, and add a _get_columns() helper function to simplify the code. Change-Id: I0087ef7dfd0130b6c47222495848c4f2b9804b1b
Diffstat (limited to 'openstackclient/network')
-rw-r--r--openstackclient/network/v2/router.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/openstackclient/network/v2/router.py b/openstackclient/network/v2/router.py
index e4eea3f8..96aa55b2 100644
--- a/openstackclient/network/v2/router.py
+++ b/openstackclient/network/v2/router.py
@@ -41,6 +41,14 @@ _formatters = {
}
+def _get_columns(item):
+ columns = item.keys()
+ if 'tenant_id' in columns:
+ columns.remove('tenant_id')
+ columns.append('project_id')
+ return tuple(sorted(columns))
+
+
def _get_attrs(client_manager, parsed_args):
attrs = {}
if parsed_args.name is not None:
@@ -129,14 +137,10 @@ class CreateRouter(command.ShowOne):
attrs = _get_attrs(self.app.client_manager, parsed_args)
obj = client.create_router(**attrs)
- columns = sorted(obj.keys())
+ columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns, formatters=_formatters)
- if 'tenant_id' in columns:
- # Rename "tenant_id" to "project_id".
- index = columns.index('tenant_id')
- columns[index] = 'project_id'
- return (tuple(columns), data)
+ return columns, data
class DeleteRouter(command.Command):
@@ -312,6 +316,6 @@ class ShowRouter(command.ShowOne):
def take_action(self, parsed_args):
client = self.app.client_manager.network
obj = client.find_router(parsed_args.router, ignore_missing=False)
- columns = sorted(obj.keys())
+ columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns, formatters=_formatters)
- return (tuple(columns), data)
+ return columns, data