Revision df5a5730 test/ganeti.jqueue_unittest.py

b/test/ganeti.jqueue_unittest.py
38 38
from ganeti import compat
39 39
from ganeti import mcpu
40 40
from ganeti import query
41
from ganeti import workerpool
41 42

  
42 43
import testutils
43 44

  
......
1625 1626
    self.assertRaises(IndexError, queue.GetNextUpdate)
1626 1627

  
1627 1628

  
1629
class TestEvaluateJobProcessorResult(unittest.TestCase):
1630
  def testFinished(self):
1631
    depmgr = _FakeDependencyManager()
1632
    job = _IdOnlyFakeJob(30953)
1633
    jqueue._EvaluateJobProcessorResult(depmgr, job,
1634
                                       jqueue._JobProcessor.FINISHED)
1635
    self.assertEqual(depmgr.GetNextNotification(), job.id)
1636
    self.assertRaises(IndexError, depmgr.GetNextNotification)
1637

  
1638
  def testDefer(self):
1639
    depmgr = _FakeDependencyManager()
1640
    job = _IdOnlyFakeJob(11326, priority=5463)
1641
    try:
1642
      jqueue._EvaluateJobProcessorResult(depmgr, job,
1643
                                         jqueue._JobProcessor.DEFER)
1644
    except workerpool.DeferTask, err:
1645
      self.assertEqual(err.priority, 5463)
1646
    else:
1647
      self.fail("Didn't raise exception")
1648
    self.assertRaises(IndexError, depmgr.GetNextNotification)
1649

  
1650
  def testWaitdep(self):
1651
    depmgr = _FakeDependencyManager()
1652
    job = _IdOnlyFakeJob(21317)
1653
    jqueue._EvaluateJobProcessorResult(depmgr, job,
1654
                                       jqueue._JobProcessor.WAITDEP)
1655
    self.assertRaises(IndexError, depmgr.GetNextNotification)
1656

  
1657
  def testOther(self):
1658
    depmgr = _FakeDependencyManager()
1659
    job = _IdOnlyFakeJob(5813)
1660
    self.assertRaises(errors.ProgrammerError,
1661
                      jqueue._EvaluateJobProcessorResult,
1662
                      depmgr, job, "Other result")
1663
    self.assertRaises(IndexError, depmgr.GetNextNotification)
1664

  
1665

  
1628 1666
class _FakeTimeoutStrategy:
1629 1667
  def __init__(self, timeouts):
1630 1668
    self.timeouts = timeouts

Also available in: Unified diff