diff --git a/magnumclient/tests/v1/test_replicationcontrollers.py b/magnumclient/tests/v1/test_replicationcontrollers.py index 9c8c736c..c42c6509 100644 --- a/magnumclient/tests/v1/test_replicationcontrollers.py +++ b/magnumclient/tests/v1/test_replicationcontrollers.py @@ -69,6 +69,21 @@ fake_responses = { UPDATED_RC, ), }, + '/v1/rcs/%s' % RC1['name']: + { + 'GET': ( + {}, + RC1 + ), + 'DELETE': ( + {}, + None, + ), + 'PATCH': ( + {}, + UPDATED_RC, + ), + }, } @@ -87,7 +102,7 @@ class RCManagerTest(testtools.TestCase): self.assertEqual(expect, self.api.calls) self.assertThat(rcs, matchers.HasLength(2)) - def test_rc_show(self): + def test_rc_show_by_id(self): rc = self.mgr.get(RC1['id']) expect = [ ('GET', '/v1/rcs/%s' % RC1['id'], {}, None) @@ -96,6 +111,15 @@ class RCManagerTest(testtools.TestCase): self.assertEqual(RC1['name'], rc.name) self.assertEqual(RC1['replicas'], rc.replicas) + def test_rc_show_by_name(self): + rc = self.mgr.get(RC1['name']) + expect = [ + ('GET', '/v1/rcs/%s' % RC1['name'], {}, None) + ] + self.assertEqual(expect, self.api.calls) + self.assertEqual(RC1['name'], rc.name) + self.assertEqual(RC1['replicas'], rc.replicas) + def test_rc_create(self): rc = self.mgr.create(**CREATE_RC) expect = [ @@ -104,7 +128,7 @@ class RCManagerTest(testtools.TestCase): self.assertEqual(expect, self.api.calls) self.assertTrue(rc) - def test_rc_delete(self): + def test_rc_delete_by_id(self): rc = self.mgr.delete(RC1['id']) expect = [ ('DELETE', '/v1/rcs/%s' % RC1['id'], {}, None), @@ -112,6 +136,14 @@ class RCManagerTest(testtools.TestCase): self.assertEqual(expect, self.api.calls) self.assertIsNone(rc) + def test_rc_delete_by_name(self): + rc = self.mgr.delete(RC1['name']) + expect = [ + ('DELETE', '/v1/rcs/%s' % RC1['name'], {}, None), + ] + self.assertEqual(expect, self.api.calls) + self.assertIsNone(rc) + def test_rc_update(self): patch = {'op': 'replace', 'value': NEW_REPLICAS, diff --git a/magnumclient/tests/v1/test_shell.py b/magnumclient/tests/v1/test_shell.py index fbb0dbac..d65c2baa 100644 --- a/magnumclient/tests/v1/test_shell.py +++ b/magnumclient/tests/v1/test_shell.py @@ -211,7 +211,7 @@ class ShellTest(base.TestCase): client_mock = mock.MagicMock() args = mock.MagicMock() rc_id = 'id' - args.id = [rc_id] + args.rcs = [rc_id] shell.do_rc_delete(client_mock, args) client_mock.rcs.delete.assert_called_once_with(rc_id) @@ -220,7 +220,7 @@ class ShellTest(base.TestCase): client_mock = mock.MagicMock() args = mock.MagicMock() rc_id = 'id' - args.id = rc_id + args.rc = rc_id shell.do_rc_show(client_mock, args) client_mock.rcs.get.assert_called_once_with(rc_id) diff --git a/magnumclient/v1/shell.py b/magnumclient/v1/shell.py index 31cd1880..4c110aaa 100644 --- a/magnumclient/v1/shell.py +++ b/magnumclient/v1/shell.py @@ -332,26 +332,26 @@ def do_rc_create(cs, args): _show_rc(rc) -@utils.arg('id', - metavar='', +@utils.arg('rcs', + metavar='', nargs='+', - help='ID of the replication (controller)s to delete.') + help='ID or name of the replication (controller)s to delete.') def do_rc_delete(cs, args): """Delete specified replication controller.""" - for id in args.id: + for rc in args.rcs: try: - cs.rcs.delete(id) + cs.rcs.delete(rc) except Exception as e: print("Delete for rc %(rc)s failed: %(e)s" % - {'rc': id, 'e': e}) + {'rc': rc, 'e': e}) -@utils.arg('id', - metavar='', - help='ID of the replication controller to show.') +@utils.arg('rc', + metavar='', + help='ID or name of the replication controller to show.') def do_rc_show(cs, args): """Show details about the given replication controller.""" - rc = cs.rcs.get(args.id) + rc = cs.rcs.get(args.rc) _show_rc(rc)