Merge "Fix router create/show if extraroute not supported"
This commit is contained in:
@@ -49,7 +49,7 @@ class RouterInfoColumn(cliff_columns.FormattableColumn):
|
|||||||
class RoutesColumn(cliff_columns.FormattableColumn):
|
class RoutesColumn(cliff_columns.FormattableColumn):
|
||||||
def human_readable(self):
|
def human_readable(self):
|
||||||
# Map the route keys to match --route option.
|
# Map the route keys to match --route option.
|
||||||
for route in self._value:
|
for route in self._value or []:
|
||||||
if 'nexthop' in route:
|
if 'nexthop' in route:
|
||||||
route['gateway'] = route.pop('nexthop')
|
route['gateway'] = route.pop('nexthop')
|
||||||
return utils.format_list_of_dicts(self._value)
|
return utils.format_list_of_dicts(self._value)
|
||||||
|
@@ -1285,6 +1285,24 @@ class TestShowRouter(TestRouter):
|
|||||||
self.assertNotIn("is_distributed", columns)
|
self.assertNotIn("is_distributed", columns)
|
||||||
self.assertNotIn("is_ha", columns)
|
self.assertNotIn("is_ha", columns)
|
||||||
|
|
||||||
|
def test_show_no_extra_route_extension(self):
|
||||||
|
_router = network_fakes.FakeRouter.create_one_router({'routes': None})
|
||||||
|
|
||||||
|
arglist = [
|
||||||
|
_router.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('router', _router.name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
with mock.patch.object(
|
||||||
|
self.network, "find_router", return_value=_router):
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.assertIn("routes", columns)
|
||||||
|
self.assertIsNone(list(data)[columns.index('routes')].human_readable())
|
||||||
|
|
||||||
|
|
||||||
class TestUnsetRouter(TestRouter):
|
class TestUnsetRouter(TestRouter):
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user