Revision 956631b6
b/lib/cli.py | ||
---|---|---|
552 | 552 |
msg = "Cannot pass options when removing parameter groups: %s" % value |
553 | 553 |
raise errors.ParameterError(msg) |
554 | 554 |
retval = (ident[len(NO_PREFIX):], False) |
555 |
elif ident.startswith(UN_PREFIX): |
|
555 |
elif (ident.startswith(UN_PREFIX) and |
|
556 |
(len(ident) <= len(UN_PREFIX) or |
|
557 |
not ident[len(UN_PREFIX)][0].isdigit())): |
|
556 | 558 |
if rest: |
557 | 559 |
msg = "Cannot pass options when removing parameter groups: %s" % value |
558 | 560 |
raise errors.ParameterError(msg) |
b/test/ganeti.cli_unittest.py | ||
---|---|---|
85 | 85 |
"""Test how we handle splitting an empty string""" |
86 | 86 |
self.failUnlessEqual(cli._SplitKeyVal("option", ""), {}) |
87 | 87 |
|
88 |
|
|
88 | 89 |
class TestIdentKeyVal(unittest.TestCase): |
89 | 90 |
"""Testing case for cli.check_ident_key_val""" |
90 | 91 |
|
... | ... | |
102 | 103 |
self.assertEqual(cikv("-foo"), ("foo", None)) |
103 | 104 |
self.assertRaises(ParameterError, cikv, "-foo:a=c") |
104 | 105 |
|
106 |
# Check negative numbers |
|
107 |
self.assertEqual(cikv("-1:remove"), ("-1", { |
|
108 |
"remove": True, |
|
109 |
})) |
|
110 |
self.assertEqual(cikv("-29447:add,size=4G"), ("-29447", { |
|
111 |
"add": True, |
|
112 |
"size": "4G", |
|
113 |
})) |
|
114 |
for i in ["-:", "-"]: |
|
115 |
self.assertEqual(cikv(i), ("", None)) |
|
116 |
|
|
105 | 117 |
|
106 | 118 |
class TestToStream(unittest.TestCase): |
107 | 119 |
"""Test the ToStream functions""" |
Also available in: Unified diff