From 4524b3605fa4260a2f916421eebfc7a99b320e4b Mon Sep 17 00:00:00 2001 From: Huanxuan Ao Date: Thu, 28 Apr 2016 11:09:49 +0800 Subject: Fix error in flavor set/unset command In the "flavor set/unset" command,the "flavor" parameter can be a name but can not be a id of a flavor. I think we should find a flavor by using "utils.find_resource()" in these commands. Change-Id: I5836788f7ed18813f1ebde31bb808b7c3f932b80 Closes-Bug: #1575624 --- openstackclient/tests/compute/v2/test_flavor.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'openstackclient/tests') diff --git a/openstackclient/tests/compute/v2/test_flavor.py b/openstackclient/tests/compute/v2/test_flavor.py index 03ca8807..fa29111b 100644 --- a/openstackclient/tests/compute/v2/test_flavor.py +++ b/openstackclient/tests/compute/v2/test_flavor.py @@ -288,8 +288,10 @@ class TestFlavorSet(TestFlavor): parsed_args = self.check_parser(self.cmd, arglist, verifylist) result = self.cmd.take_action(parsed_args) - - self.flavors_mock.find.assert_called_with(name='baremetal') + try: + self.flavors_mock.find.assert_called_with(name=parsed_args.flavor) + except Exception: + self.flavors_mock.get.assert_called_with(parsed_args.flavor) self.assertIsNone(result) @@ -382,6 +384,8 @@ class TestFlavorUnset(TestFlavor): parsed_args = self.check_parser(self.cmd, arglist, verifylist) result = self.cmd.take_action(parsed_args) - - self.flavors_mock.find.assert_called_with(name='baremetal') + try: + self.flavors_mock.find.assert_called_with(name=parsed_args.flavor) + except Exception: + self.flavors_mock.get.assert_called_with(parsed_args.flavor) self.assertIsNone(result) -- cgit v1.2.1