Revision 9440aeab test/ganeti.utils_unittest.py

b/test/ganeti.utils_unittest.py
38 38
     RemoveFile, CheckDict, MatchNameComponent, FormatUnit, \
39 39
     ParseUnit, AddAuthorizedKey, RemoveAuthorizedKey, \
40 40
     ShellQuote, ShellQuoteArgs, TcpPing, ListVisibleFiles, \
41
     AddEtcHostsEntry, RemoveEtcHostsEntry
41
     SetEtcHostsEntry, RemoveEtcHostsEntry
42 42
from ganeti.errors import LockError, UnitParseError
43 43

  
44 44

  
......
447 447

  
448 448
    return tmpname
449 449

  
450
  def testAddingNewIp(self):
450
  def testSettingNewIp(self):
451 451
    tmpname = self.writeTestFile()
452 452
    try:
453
      AddEtcHostsEntry(tmpname, 'myhost.domain.tld', '1.2.3.4')
453
      SetEtcHostsEntry(tmpname, '1.2.3.4', 'myhost.domain.tld', ['myhost'])
454 454

  
455 455
      f = open(tmpname, 'r')
456 456
      try:
457 457
        self.assertEqual(md5.new(f.read(8192)).hexdigest(),
458
                         '00e0e88250482e7449743c89a49e9349')
458
                         '410c141dcafffd505f662a41713d2eab')
459 459
      finally:
460 460
        f.close()
461 461
    finally:
462 462
      os.unlink(tmpname)
463 463

  
464
  def testAddingExistingIp(self):
464
  def testSettingExistingIp(self):
465 465
    tmpname = self.writeTestFile()
466 466
    try:
467
      AddEtcHostsEntry(tmpname, 'myhost.domain.tld', '192.168.1.1')
467
      SetEtcHostsEntry(tmpname, '192.168.1.1', 'myhost.domain.tld', ['myhost'])
468 468

  
469 469
      f = open(tmpname, 'r')
470 470
      try:
471 471
        self.assertEqual(md5.new(f.read(8192)).hexdigest(),
472
                         '4dc04c0acdd247175e0b980c6beea822')
472
                         'bbf60c542dec949f3968b59522ec0d7b')
473 473
      finally:
474 474
        f.close()
475 475
    finally:
......
483 483
      f = open(tmpname, 'r')
484 484
      try:
485 485
        self.assertEqual(md5.new(f.read(8192)).hexdigest(),
486
                         '7d1e7a559eedbc25e0dff67d33ccac84')
486
                         '8b09207a23709d60240674601a3548b2')
487 487
      finally:
488 488
        f.close()
489 489
    finally:
......
517 517
    finally:
518 518
      os.unlink(tmpname)
519 519

  
520
  def testRemovingAlias(self):
521
    tmpname = self.writeTestFile()
522
    try:
523
      RemoveEtcHostsEntry(tmpname, 'gw')
524

  
525
      f = open(tmpname, 'r')
526
      try:
527
        self.assertEqual(md5.new(f.read(8192)).hexdigest(),
528
                         '156dd3980a17b2ef934e2d0bf670aca2')
529
      finally:
530
        f.close()
531
    finally:
532
      os.unlink(tmpname)
533

  
520 534

  
521 535
class TestShellQuoting(unittest.TestCase):
522 536
  """Test case for shell quoting functions"""

Also available in: Unified diff