Fix errors in `set/unset flavor
` unit tests
1. We should assert flavor.set_keys() is called correctly or not called in ``set flavor`` unit tests. 2. Commit c7e6973ff50ff84af9ad55f7bdaeeea83ae40f0b from me removed test_flavor_unset_no_project which used to test if --project was specified as '', and assert CommandError was raised, which is incorrect. So I removed it. But after looking into the code, I think we should not remove it, but specify nothing after --project, and assert ParserException was raised. So in this patch, we fix it as so. ('--project', '') --> ('--project') assert CommandError --> assert ParserException Change-Id: Ifd33c72d5b7581aaabffb09e9b5e38ecc67e18c0
This commit is contained in:
parent
2c92b60f45
commit
c4b590748a
@ -469,6 +469,7 @@ class TestFlavorSet(TestFlavor):
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.flavors_mock.find.assert_called_with(name=parsed_args.flavor,
|
||||
is_public=None)
|
||||
self.flavor.set_keys.assert_called_with({'FOO': '"B A R"'})
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_flavor_set_project(self):
|
||||
@ -483,12 +484,15 @@ class TestFlavorSet(TestFlavor):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.assertIsNone(result)
|
||||
|
||||
self.flavors_mock.find.assert_called_with(name=parsed_args.flavor,
|
||||
is_public=None)
|
||||
self.flavor_access_mock.add_tenant_access.assert_called_with(
|
||||
self.flavor.id,
|
||||
identity_fakes.project_id,
|
||||
)
|
||||
self.flavor.set_keys.assert_not_called()
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_flavor_set_no_project(self):
|
||||
arglist = [
|
||||
@ -496,7 +500,7 @@ class TestFlavorSet(TestFlavor):
|
||||
self.flavor.id,
|
||||
]
|
||||
verifylist = [
|
||||
('project', ''),
|
||||
('project', None),
|
||||
('flavor', self.flavor.id),
|
||||
]
|
||||
self.assertRaises(tests_utils.ParserException, self.check_parser,
|
||||
@ -509,12 +513,8 @@ class TestFlavorSet(TestFlavor):
|
||||
verifylist = [
|
||||
('project', identity_fakes.project_id),
|
||||
]
|
||||
|
||||
self.assertRaises(tests_utils.ParserException,
|
||||
self.check_parser,
|
||||
self.cmd,
|
||||
arglist,
|
||||
verifylist)
|
||||
self.assertRaises(tests_utils.ParserException, self.check_parser,
|
||||
self.cmd, arglist, verifylist)
|
||||
|
||||
def test_flavor_set_with_unexist_flavor(self):
|
||||
self.flavors_mock.get.side_effect = exceptions.NotFound(None)
|
||||
@ -541,7 +541,6 @@ class TestFlavorSet(TestFlavor):
|
||||
verifylist = [
|
||||
('flavor', self.flavor.id),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
|
||||
parsed_args)
|
||||
@ -672,6 +671,18 @@ class TestFlavorUnset(TestFlavor):
|
||||
self.flavor.unset_keys.assert_not_called()
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_flavor_unset_no_project(self):
|
||||
arglist = [
|
||||
'--project',
|
||||
self.flavor.id,
|
||||
]
|
||||
verifylist = [
|
||||
('project', None),
|
||||
('flavor', self.flavor.id),
|
||||
]
|
||||
self.assertRaises(tests_utils.ParserException, self.check_parser,
|
||||
self.cmd, arglist, verifylist)
|
||||
|
||||
def test_flavor_unset_no_flavor(self):
|
||||
arglist = [
|
||||
'--project', identity_fakes.project_id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user