Revision 8b46606c test/ganeti.cli_unittest.py

b/test/ganeti.cli_unittest.py
79 79
    """Test how we handle splitting an empty string"""
80 80
    self.failUnlessEqual(cli._SplitKeyVal("option", ""), {})
81 81

  
82
class TestIdentKeyVal(unittest.TestCase):
83
  """Testing case for cli.check_ident_key_val"""
84

  
85
  def testIdentKeyVal(self):
86
    """Test identkeyval"""
87
    def cikv(value):
88
      return cli.check_ident_key_val("option", "opt", value)
89

  
90
    self.assertEqual(cikv("foo:bar"), ("foo", {"bar": True}))
91
    self.assertEqual(cikv("foo:bar=baz"), ("foo", {"bar": "baz"}))
92
    self.assertEqual(cikv("bar:b=c,c=a"), ("bar", {"b": "c", "c": "a"}))
93
    self.assertEqual(cikv("no_bar"), ("bar", False))
94
    self.assertRaises(ParameterError, cikv, "no_bar:foo")
95
    self.assertRaises(ParameterError, cikv, "no_bar:foo=baz")
96
    self.assertEqual(cikv("-foo"), ("foo", None))
97
    self.assertRaises(ParameterError, cikv, "-foo:a=c")
98

  
82 99

  
83 100
class TestToStream(unittest.TestCase):
84 101
  """Thes the ToStream functions"""

Also available in: Unified diff