def test_get_class_by_path_invalid_class_name(self): try: prod_web_config = utils.get_class_by_path("sigurd.tests.configs.project_complex.BlablaProdWebConfig") self.fail("AttributeError was not called for wrong class name") except AttributeError: # OK pass
def test_get_class_by_path_invalid_path(self): try: prod_web_config = utils.get_class_by_path("sigurd.blabla.project_complex.ProdWebConfig") self.fail("ImportError was not called for wrong package pass") except ImportError: # OK pass
def test_get_class_by_path_invalid_class_name(self): try: prod_web_config = utils.get_class_by_path( "sigurd.tests.configs.project_complex.BlablaProdWebConfig") self.fail("AttributeError was not called for wrong class name") except AttributeError: # OK pass
def test_get_class_by_path_invalid_path(self): try: prod_web_config = utils.get_class_by_path( "sigurd.blabla.project_complex.ProdWebConfig") self.fail("ImportError was not called for wrong package pass") except ImportError: # OK pass
def install_app(self, app_config): """ Installs application config. app_config can be class or string with python path to class. """ if isinstance(app_config, basestring): try: app_config = utils.get_class_by_path(app_config) except (ImportError, AttributeError), e: raise ConfigurationError( "Project config[%s]: Cannot install application config [%s] because of error: %s " % (self.__class__.__name__, str(app_config), str(e)))
def install_app(self, app_config): """ Installs application config. app_config can be class or string with python path to class. """ if isinstance(app_config, basestring): try: app_config = utils.get_class_by_path(app_config) except (ImportError, AttributeError), e: raise ConfigurationError( "Project config[%s]: Cannot install application config [%s] because of error: %s " % ( self.__class__.__name__, str(app_config), str(e)))
def test_get_class_by_path(self): prod_web_config = utils.get_class_by_path( "sigurd.tests.configs.project_complex.ProdWebConfig") self.assertEquals(ProdWebConfig, prod_web_config)
def test_get_class_by_path(self): prod_web_config = utils.get_class_by_path("sigurd.tests.configs.project_complex.ProdWebConfig") self.assertEquals(ProdWebConfig, prod_web_config)