def test_from_string(self): descriptor = Descriptor.from_string(None) assert descriptor is None descriptor = Descriptor.from_string( "pip-dummies:controller:default:default:1.0") assert descriptor.exact_match( Descriptor("pip-dummies", "controller", "default", "default", "1.0")) with pytest.raises(ConfigException) as ex: Descriptor.from_string('xxx')
def from_config(config: ConfigParams) -> 'ComponentConfig': """ Creates a new instance of ComponentConfig based on section from container configuration. :param config: component parameters from container configuration :return: a newly created ComponentConfig """ descriptor = Descriptor.from_string(config.get_as_nullable_string("descriptor")) type = TypeDescriptor.from_string(config.get_as_nullable_string("type")) if descriptor is None and type is None: raise ConfigException(None, "BAD_CONFIG", "Component configuration must have descriptor or type") return ComponentConfig(descriptor, type, config)