Esempio n. 1
0
 def setup_config(self, filename, images_dir=None, context_name=None):
     if images_dir is None:
         images_dir = fixtures.TempDir()
         self.useFixture(images_dir)
     build_log_dir = fixtures.TempDir()
     self.useFixture(build_log_dir)
     if filename.startswith('/'):
         path = filename
     else:
         configfile = os.path.join(os.path.dirname(__file__), 'fixtures',
                                   filename)
         (fd, path) = tempfile.mkstemp()
         with open(configfile, 'rb') as conf_fd:
             config = conf_fd.read().decode('utf8')
             data = config.format(images_dir=images_dir.path,
                                  build_log_dir=build_log_dir.path,
                                  context_name=context_name,
                                  zookeeper_host=self.zookeeper_host,
                                  zookeeper_port=self.zookeeper_port,
                                  zookeeper_chroot=self.zookeeper_chroot)
             os.write(fd, data.encode('utf8'))
         os.close(fd)
     self._config_images_dir = images_dir
     self._config_build_log_dir = build_log_dir
     validator = ConfigValidator(path)
     validator.validate()
     return path
Esempio n. 2
0
 def setup_config(self, filename, images_dir=None):
     if images_dir is None:
         images_dir = fixtures.TempDir()
         self.useFixture(images_dir)
     configfile = os.path.join(os.path.dirname(__file__), 'fixtures',
                               filename)
     (fd, path) = tempfile.mkstemp()
     with open(configfile) as conf_fd:
         config = conf_fd.read()
         os.write(
             fd,
             config.format(images_dir=images_dir.path,
                           gearman_port=self.gearman_server.port,
                           zookeeper_host=self.zookeeper_host,
                           zookeeper_port=self.zookeeper_port,
                           zookeeper_chroot=self.zookeeper_chroot))
     os.close(fd)
     self._config_images_dir = images_dir
     validator = ConfigValidator(path)
     validator.validate()
     return path
Esempio n. 3
0
 def config_validate(self):
     validator = ConfigValidator(self.args.config)
     validator.validate()
     log.info("Configuration validation complete")
Esempio n. 4
0
 def test_static_validator(self):
     config = os.path.join(os.path.dirname(tests.__file__), 'fixtures',
                           'config_validate', 'static_error.yaml')
     validator = ConfigValidator(config)
     self.assertRaises(MultipleInvalid, validator.validate)
Esempio n. 5
0
    def test_yaml_error(self):
        config = os.path.join(os.path.dirname(tests.__file__), 'fixtures',
                              'config_validate', 'yaml_error.yaml')

        validator = ConfigValidator(config)
        self.assertRaises(ParserError, validator.validate)
Esempio n. 6
0
    def test_good_config(self):
        config = os.path.join(os.path.dirname(tests.__file__), 'fixtures',
                              'config_validate', 'good.yaml')

        validator = ConfigValidator(config)
        validator.validate()