Revision e80edd3b test/py/qa.qa_config_unittest.py

b/test/py/qa.qa_config_unittest.py
350 350
                      exclude=acquired, _cfg=self.config)
351 351

  
352 352

  
353
class TestRepresentation(unittest.TestCase):
354
  def _Check(self, target, part):
355
    self.assertTrue(part in repr(target).split())
356

  
357
  def testQaInstance(self):
358
    inst = qa_config._QaInstance("inst1.example.com", [])
359
    self._Check(inst, "name=inst1.example.com")
360
    self._Check(inst, "nicmac=[]")
361

  
362
    # Default values
363
    self._Check(inst, "disk_template=None")
364
    self._Check(inst, "used=None")
365

  
366
    # Use instance
367
    inst.Use()
368
    self._Check(inst, "used=True")
369

  
370
    # Disk template
371
    inst.SetDiskTemplate(constants.DT_DRBD8)
372
    self._Check(inst, "disk_template=%s" % constants.DT_DRBD8)
373

  
374
    # Release instance
375
    inst.Release()
376
    self._Check(inst, "used=False")
377
    self._Check(inst, "disk_template=None")
378

  
379
  def testQaNode(self):
380
    node = qa_config._QaNode("primary.example.com", "192.0.2.1")
381
    self._Check(node, "primary=primary.example.com")
382
    self._Check(node, "secondary=192.0.2.1")
383
    self._Check(node, "added=False")
384
    self._Check(node, "use_count=0")
385

  
386
    # Mark as added
387
    node.MarkAdded()
388
    self._Check(node, "added=True")
389

  
390
    # Use node
391
    for i in range(1, 5):
392
      node.Use()
393
      self._Check(node, "use_count=%s" % i)
394

  
395
    # Release node
396
    for i in reversed(range(1, 5)):
397
      node.Release()
398
      self._Check(node, "use_count=%s" % (i - 1))
399

  
400
    self._Check(node, "use_count=0")
401

  
402
    # Mark as added
403
    node.MarkRemoved()
404
    self._Check(node, "added=False")
405

  
406

  
353 407
if __name__ == "__main__":
354 408
  testutils.GanetiTestProgram()

Also available in: Unified diff