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()
  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])
  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()
  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()
  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()
  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()