def test_init_wrongs_params(self):
   """
   Test init with wrongs params
   """
   clazz = classloader.load('clu.common.base.Configurable')
   with self.assertRaisesRegexp(classloader.ClassLoaderException, "__init__()"):
     instance = classloader.init(clazz, { "onfig" : {"one":1}} )
 def test_init(self):
   """
   Test init with params
   """
   clazz = classloader.load('clu.common.base.Configurable')
   instance = classloader.init(clazz, { "config" : {"one":1}} )
   self.assertFalse(instance.config is None)
   self.assertTrue(instance.config.one == 1)
  def initalize_all(self):
    """ Load configure """
    agents_conf = {}
    if self._loadedconfig.has_key("configs"):
      agents_conf = self._loadedconfig["configs"]
    else:
      LOGGER.debug("No config at all. All Agent will have efault values.")

    for agent_name in self.__clazzs__:
      LOGGER.debug("Initializing '%s'", agent_name)
      conf = {}
      if agents_conf.has_key(agent_name):
        conf = agents_conf[agent_name]
        LOGGER.debug("Found conf for agent '%s'", agent_name)
      else:
        LOGGER.debug("No conf found for agent '%s'", agent_name)
      # Here is the magic : get the Class instance
      clazz = self.__clazzs__[agent_name]
      instance = classloader.init(clazz, conf)
      # We have our instance.
      self.agents.append(instance)
      LOGGER.info("'%s' is fully loaded", agent_name)
 def test_init_none(self):
   """
   Test init with params None
   """
   with self.assertRaises(classloader.ClassLoaderException): 
     classloader.init(None, None)