summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorTang Chen <chen.tang@easystack.cn>2016-02-04 13:19:01 +0800
committerTang Chen <chen.tang@easystack.cn>2016-02-27 04:53:10 +0800
commit01c19ef0bc6abc0dbbd76666bdc0c5dda7ba0196 (patch)
treef0fa9c613d4928e0fed307af15370c6bf976b6c7 /openstackclient/tests
parentada06f4dc3df39db5e739ebd8d82ccd734a54a93 (diff)
downloadpython-openstackclient-01c19ef0bc6abc0dbbd76666bdc0c5dda7ba0196.tar.gz
Router: Add --route and --clear-routes options to "router set" command
--route option is used to set routes to the router. It is used like this: --route destination=subnet,gateway=ip-address destination: destination subnet CIDR gateway: nexthop IP address --clear-routes is used to clear all routes on the router. Change-Id: I97ce4871113c684b29c98cdad4dec9cc80ed20f7 Implements: blueprint neutron-client Partial-bug: #1519503
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/network/v2/test_router.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/openstackclient/tests/network/v2/test_router.py b/openstackclient/tests/network/v2/test_router.py
index 05bb7857..794f8ab5 100644
--- a/openstackclient/tests/network/v2/test_router.py
+++ b/openstackclient/tests/network/v2/test_router.py
@@ -306,6 +306,63 @@ class TestSetRouter(TestRouter):
self.assertRaises(tests_utils.ParserException, self.check_parser,
self.cmd, arglist, verifylist)
+ def test_set_route(self):
+ arglist = [
+ self._router.name,
+ '--route', 'destination=10.20.30.0/24,gateway=10.20.30.1',
+ ]
+ verifylist = [
+ ('router', self._router.name),
+ ('routes', [{'destination': '10.20.30.0/24',
+ 'gateway': '10.20.30.1'}]),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.take_action(parsed_args)
+
+ attrs = {
+ 'routes': [{'destination': '10.20.30.0/24',
+ 'gateway': '10.20.30.1'}],
+ }
+ self.network.update_router.assert_called_with(self._router, **attrs)
+ self.assertIsNone(result)
+
+ def test_set_clear_routes(self):
+ arglist = [
+ self._router.name,
+ '--clear-routes',
+ ]
+ verifylist = [
+ ('router', self._router.name),
+ ('clear_routes', True),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.take_action(parsed_args)
+
+ attrs = {
+ 'routes': [],
+ }
+ self.network.update_router.assert_called_with(self._router, **attrs)
+ self.assertIsNone(result)
+
+ def test_set_route_clear_routes(self):
+ arglist = [
+ self._router.name,
+ '--route', 'destination=10.20.30.0/24,gateway=10.20.30.1',
+ '--clear-routes',
+ ]
+ verifylist = [
+ ('router', self._router.name),
+ ('routes', [{'destination': '10.20.30.0/24',
+ 'gateway': '10.20.30.1'}]),
+ ('clear_routes', True),
+ ]
+
+ # Argument parse failing should bail here
+ self.assertRaises(tests_utils.ParserException, self.check_parser,
+ self.cmd, arglist, verifylist)
+
def test_set_nothing(self):
arglist = [self._router.name, ]
verifylist = [('router', self._router.name), ]