def test_valid(self):
     validator = Validator(SCHEMA)
     for s in (VALID,
               MISSING_OPTIONAL_SECTION,
               MISSING_OPTIONAL_PROPERTY,
               TEST_MISSING_OPTIONAL_VALUE,):
         cfg = self.read(s)
         validator.validate(cfg)
예제 #2
0
 def test_valid(self):
     validator = Validator(SCHEMA)
     for s in (
             VALID,
             MISSING_OPTIONAL_SECTION,
             MISSING_OPTIONAL_PROPERTY,
             TEST_MISSING_OPTIONAL_VALUE,
     ):
         cfg = self.read(s)
         validator.validate(cfg)
예제 #3
0
파일: container.py 프로젝트: alexxa/pulp
 def __init__(self, name, path):
     """
     @param name: The handler name.
     @type name: str
     @param path: The absolute path to the descriptor.
     @type path: str
     """
     cfg = Config(path)
     validator = Validator(self.SCHEMA)
     validator.validate(cfg)
     self.name = name
     self.cfg = cfg
예제 #4
0
 def __init__(self, name, path):
     """
     @param name: The handler name.
     @type name: str
     @param path: The absolute path to the descriptor.
     @type path: str
     """
     cfg = Config(path)
     validator = Validator(self.SCHEMA)
     validator.validate(cfg)
     self.name = name
     self.cfg = cfg
예제 #5
0
파일: container.py 프로젝트: ehelms/pulp
 def __init__(self, cfg, section):
     """
     Construct the object and validate the configuration.
     @param cfg: The descriptor configuration.
     @type cfg: INIConfig
     @param section: The typedef section name within the descriptor.
     @type section: str
     """
     schema = (
         (section, REQUIRED,
             (
                 ('class', REQUIRED, ANY),
             ),
          ),)
     cfg = Config(cfg, filter=[section])
     validator = Validator(schema)
     validator.validate(cfg)
     self.cfg = cfg[section]
예제 #6
0
def is_valid(source_id, descriptor):
    """
    Get whether a content source descriptor is valid.
    :param source_id: A content source ID.
    :type source_id: str
    :param descriptor: A content source descriptor.
    :type descriptor: dict
    :return: True if valid.
    :rtype: bool
    """
    try:
        schema = list(SCHEMA)
        schema[0] = source_id
        validator = Validator((schema, ))
        cfg = Config({source_id: descriptor})
        validator.validate(cfg)
        return True
    except ValidationException, e:
        log.error(str(e))
예제 #7
0
 def test_invalid(self):
     validator = Validator(SCHEMA)
     for s in (
             MISSING_REQUIRED_SECTION,
             MISSING_REQUIRED_PROPERTY,
             TEST_MISSING_REQUIRED_VALUE,
             TEST_INVALID_VALUE,
     ):
         cfg = self.read(s)
         self.assertRaises(ValidationException, validator.validate, cfg)
예제 #8
0
파일: descriptor.py 프로젝트: ashcrow/pulp
def is_valid(source_id, descriptor):
    """
    Get whether a content source descriptor is valid.
    :param source_id: A content source ID.
    :type source_id: str
    :param descriptor: A content source descriptor.
    :type descriptor: dict
    :return: True if valid.
    :rtype: bool
    """
    try:
        schema = list(SCHEMA)
        schema[0] = source_id
        validator = Validator((schema,))
        cfg = Config({source_id: descriptor})
        validator.validate(cfg)
        return True
    except ValidationException, e:
        log.error(str(e))
예제 #9
0
 def __init__(self, cfg, section):
     """
     Construct the object and validate the configuration.
     @param cfg: The descriptor configuration.
     @type cfg: Config
     @param section: The typedef section name within the descriptor.
     @type section: str
     """
     schema = ((
         section,
         REQUIRED,
         (('class', REQUIRED, ANY), ),
     ), )
     cfg = Config(cfg, filter=[section])
     if cfg:
         validator = Validator(schema)
         validator.validate(cfg)
         self.cfg = cfg[section]
     else:
         raise SectionNotFound(section)