Commit 7a70541e authored by Michael Hanselmann's avatar Michael Hanselmann

Add missing tests for commit f0d22861

Commit f0d22861 changed the logic of
gnt_instance._ConvertNicDiskModifications to also allow a parameter
named “modify”. Unfortunately the corresponding unittest was not
updated. An “if”/“else” condition is also merged.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 1251817b
......@@ -1323,12 +1323,11 @@ def _ConvertNicDiskModifications(mods):
else:
action = constants.DDM_MODIFY
elif add is _MISSING and remove is _MISSING:
action = constants.DDM_MODIFY
else:
if add is _MISSING and remove is _MISSING:
action = constants.DDM_MODIFY
else:
raise errors.OpPrereqError("Cannot modify and add/remove at the"
" same time", errors.ECODE_INVAL)
raise errors.OpPrereqError("Cannot modify and add/remove at the"
" same time", errors.ECODE_INVAL)
assert not (constants.DDMS_VALUES_WITH_MODIFY & set(params.keys()))
......
......@@ -149,6 +149,12 @@ class TestConvertNicDiskModifications(unittest.TestCase):
]), [
(action, -1, {}),
])
self.assertRaises(errors.OpPrereqError, fn, [
(0, {
action: True,
constants.DDM_MODIFY: True,
}),
])
self.assertEqual(fn([
(constants.DDM_ADD, {
......@@ -190,6 +196,17 @@ class TestConvertNicDiskModifications(unittest.TestCase):
(constants.DDM_REMOVE, -1, {}),
])
self.assertEqual(fn([
(-1, {
constants.DDM_MODIFY: True,
constants.IDISK_SIZE: 1024,
}),
]), [
(constants.DDM_MODIFY, -1, {
constants.IDISK_SIZE: 1024,
}),
])
class TestParseDiskSizes(unittest.TestCase):
def test(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment