diff options
| author | Richard Theis <rtheis@us.ibm.com> | 2016-04-05 13:27:42 -0500 |
|---|---|---|
| committer | Richard Theis <rtheis@us.ibm.com> | 2016-04-18 13:35:38 -0500 |
| commit | a90c824e0407f931b5c45df53103b43aa564de12 (patch) | |
| tree | 2a11f8529ecac6a14516c9013625de1a8912e272 /openstackclient/tests/network | |
| parent | e3a6fc27b0cfc9b82801e13d61c2fad3a09bf6b1 (diff) | |
| download | python-openstackclient-a90c824e0407f931b5c45df53103b43aa564de12.tar.gz | |
Fix router set --route option
Fix the "--route" option on the "os router set" command. The
option did not properly format the new routes to set which
resulted in a "HttpException: Bad Request" error. In addition,
the output for routes was fixed to improve readability and to
align with the "--route" option on the "os router set" command.
Change-Id: I9c514153ec201e2feae32be6dd281771e3298b9c
Closes-Bug: #1564460
Diffstat (limited to 'openstackclient/tests/network')
| -rw-r--r-- | openstackclient/tests/network/v2/fakes.py | 6 | ||||
| -rw-r--r-- | openstackclient/tests/network/v2/test_router.py | 15 |
2 files changed, 13 insertions, 8 deletions
diff --git a/openstackclient/tests/network/v2/fakes.py b/openstackclient/tests/network/v2/fakes.py index 5fd7ea3b..73c6b09e 100644 --- a/openstackclient/tests/network/v2/fakes.py +++ b/openstackclient/tests/network/v2/fakes.py @@ -328,7 +328,7 @@ class FakeRouter(object): """Fake one or more routers.""" @staticmethod - def create_one_router(attrs={}): + def create_one_router(attrs=None): """Create a fake router. :param Dictionary attrs: @@ -337,6 +337,8 @@ class FakeRouter(object): A FakeResource object, with id, name, admin_state_up, status, tenant_id """ + attrs = attrs or {} + # Set default attributes. router_attrs = { 'id': 'router-id-' + uuid.uuid4().hex, @@ -364,7 +366,7 @@ class FakeRouter(object): return router @staticmethod - def create_routers(attrs={}, count=2): + def create_routers(attrs=None, count=2): """Create multiple fake routers. :param Dictionary attrs: diff --git a/openstackclient/tests/network/v2/test_router.py b/openstackclient/tests/network/v2/test_router.py index e8041498..e3f32e4a 100644 --- a/openstackclient/tests/network/v2/test_router.py +++ b/openstackclient/tests/network/v2/test_router.py @@ -138,7 +138,7 @@ class TestCreateRouter(TestRouter): new_router.id, new_router.name, new_router.tenant_id, - new_router.routes, + router._format_routes(new_router.routes), new_router.status, ) @@ -268,7 +268,7 @@ class TestListRouter(TestRouter): r = routers[i] data_long.append( data[i] + ( - r.routes, + router._format_routes(r.routes), router._format_external_gateway_info(r.external_gateway_info), osc_utils.format_list(r.availability_zones), ) @@ -399,7 +399,10 @@ class TestRemoveSubnetFromRouter(TestRouter): class TestSetRouter(TestRouter): # The router to set. - _router = network_fakes.FakeRouter.create_one_router() + _default_route = {'destination': '10.20.20.0/24', 'nexthop': '10.20.30.1'} + _router = network_fakes.FakeRouter.create_one_router( + attrs={'routes': [_default_route]} + ) def setUp(self): super(TestSetRouter, self).setUp() @@ -491,8 +494,8 @@ class TestSetRouter(TestRouter): result = self.cmd.take_action(parsed_args) attrs = { - 'routes': [{'destination': '10.20.30.0/24', - 'gateway': '10.20.30.1'}], + 'routes': self._router.routes + [{'destination': '10.20.30.0/24', + 'nexthop': '10.20.30.1'}], } self.network.update_router.assert_called_once_with( self._router, **attrs) @@ -572,7 +575,7 @@ class TestShowRouter(TestRouter): _router.id, _router.name, _router.tenant_id, - _router.routes, + router._format_routes(_router.routes), _router.status, ) |
