From 50443127c56e4de94bdd141ce22900d63736fbea Mon Sep 17 00:00:00 2001 From: Tang Chen Date: Thu, 3 Mar 2016 20:50:17 +0800 Subject: 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 --- openstackclient/tests/network/v2/fakes.py | 4 ++++ openstackclient/tests/network/v2/test_router.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'openstackclient/tests') diff --git a/openstackclient/tests/network/v2/fakes.py b/openstackclient/tests/network/v2/fakes.py index cfd05729..9e6bf97f 100644 --- a/openstackclient/tests/network/v2/fakes.py +++ b/openstackclient/tests/network/v2/fakes.py @@ -370,6 +370,10 @@ class FakeRouter(object): router = fakes.FakeResource(info=copy.deepcopy(router_attrs), methods=copy.deepcopy(router_methods), loaded=True) + + # Set attributes with special mapping in OpenStack SDK. + router.project_id = router_attrs['tenant_id'] + return router @staticmethod diff --git a/openstackclient/tests/network/v2/test_router.py b/openstackclient/tests/network/v2/test_router.py index 794f8ab5..68c225e7 100644 --- a/openstackclient/tests/network/v2/test_router.py +++ b/openstackclient/tests/network/v2/test_router.py @@ -383,7 +383,7 @@ class TestShowRouter(TestRouter): 'ha', 'id', 'name', - 'tenant_id', + 'project_id', ) data = ( @@ -392,7 +392,7 @@ class TestShowRouter(TestRouter): _router.ha, _router.id, _router.name, - _router.tenant_id, + _router.project_id, ) def setUp(self): -- cgit v1.2.1