Exemplo n.º 1
0
  def test_init_scheduler_unknown_scheduler(self):
    """ Test AgentRunner with parameters """
    instance = Mock()
    instance.config.scheduling.name = "BAD SCHEDULER"

    co = AgentRunner(instance)
    with self.assertRaisesRegexp(AgentRunnerException, "Scheduling strategies not found"):
      co._init_scheduler()
Exemplo n.º 2
0
  def test_init_scheduler_none_scheduler(self):
    """ Test AgentRunner scheduler instanciation """

    instance = Mock()
    instance.config.scheduling.name = None

    co = AgentRunner(instance)
    co._init_scheduler()
    self.assertTrue(co.scheduler.__class__ is SCHEDULERS[None])
Exemplo n.º 3
0
  def test_start_no_instance(self):
    """ Test AgentRunner with parameters """
    sched = {"scheduling":{"name": "A SCHEDULER"}}
    instance = None
    mock = Mock()

    co = AgentRunner(instance)

    with self.assertRaisesRegexp(AgentRunnerException, "Can't init a runner for a None module !"):
      co._init_scheduler()
Exemplo n.º 4
0
  def test_stop_no_scheduler(self):
    """ Test AgentRunner with parameters """
    sched = {"scheduling":{"name": "A SCHEDULER"}}
    instance = Mock()
    mock = Mock()

    co = AgentRunner(instance)
    co._init_scheduler = mock

    with self.assertRaisesRegexp(AgentRunnerException, "No scheduler found"):
      co.stop()
Exemplo n.º 5
0
  def test_start_no_scheduler(self):
    """ Test AgentRunner with parameters """
    instance = Mock()
    mock = Mock()
    instance.config.scheduling.name = "A SCHEDULER"

    co = AgentRunner(instance)
    co._init_scheduler = mock

    with self.assertRaisesRegexp(AgentRunnerException, "No scheduler found"):
      co.start()
Exemplo n.º 6
0
  def test_start_a_scheduler(self):
    """ Test AgentRunner with parameters """
    sched = {"scheduling":{"name": "A SCHEDULER"}}
    mock = Mock()
    mocked_sched = Mock()
    instance = Mock()

    co = AgentRunner(instance)
    co._init_scheduler = mock
    co.scheduler = mocked_sched

    co.start()
    mocked_sched.start.assert_called_with()