Revision 31e22135 test/ganeti.utils_unittest.py

b/test/ganeti.utils_unittest.py
40 40
from ganeti import utils
41 41
from ganeti import errors
42 42
from ganeti.utils import IsProcessAlive, RunCmd, \
43
     RemoveFile, CheckDict, MatchNameComponent, FormatUnit, \
43
     RemoveFile, MatchNameComponent, FormatUnit, \
44 44
     ParseUnit, AddAuthorizedKey, RemoveAuthorizedKey, \
45 45
     ShellQuote, ShellQuoteArgs, TcpPing, ListVisibleFiles, \
46 46
     SetEtcHostsEntry, RemoveEtcHostsEntry, FirstFree, OwnIpAddress, \
......
306 306
                     mkdir=True)
307 307

  
308 308

  
309
class TestCheckdict(unittest.TestCase):
310
  """Test case for the CheckDict function"""
311

  
312
  def testAdd(self):
313
    """Test that CheckDict adds a missing key with the correct value"""
314

  
315
    tgt = {'a':1}
316
    tmpl = {'b': 2}
317
    CheckDict(tgt, tmpl)
318
    if 'b' not in tgt or tgt['b'] != 2:
319
      self.fail("Failed to update dict")
320

  
321

  
322
  def testNoUpdate(self):
323
    """Test that CheckDict does not overwrite an existing key"""
324
    tgt = {'a':1, 'b': 3}
325
    tmpl = {'b': 2}
326
    CheckDict(tgt, tmpl)
327
    self.failUnlessEqual(tgt['b'], 3)
328

  
329

  
330 309
class TestMatchNameComponent(unittest.TestCase):
331 310
  """Test case for the MatchNameComponent function"""
332 311

  

Also available in: Unified diff