Ejemplo n.º 1
0
    def testConflictingMassagerRegistration(self):
        from ploy.config import BooleanMassager, IntegerMassager

        config = Config(StringIO('')).parse()
        config.add_massager(BooleanMassager('section', 'value'))
        with pytest.raises(ValueError) as e:
            config.add_massager(IntegerMassager('section', 'value'))
        assert unicode(e.value) == "Massager for option 'value' in section group 'section' already registered."
Ejemplo n.º 2
0
    def testConflictingMassagerRegistration(self):
        from ploy.config import BooleanMassager, IntegerMassager

        config = Config(StringIO('')).parse()
        config.add_massager(BooleanMassager('section', 'value'))
        with pytest.raises(ValueError) as e:
            config.add_massager(IntegerMassager('section', 'value'))
        assert unicode(
            e.value
        ) == "Massager for option 'value' in section group 'section' already registered."
Ejemplo n.º 3
0
 def testExtendFromDifferentDirectoryWithMassager(self):
     from ploy.config import PathMassager
     os.mkdir(os.path.join(self.directory, 'bar'))
     ployconf = 'ploy.conf'
     self._write_config(
         ployconf,
         '\n'.join(['[global]', 'extends = bar/foo.conf', 'ham = egg']))
     self._write_config(
         'bar/foo.conf',
         '\n'.join(['[global]', 'foo = blubber', 'ham = pork']))
     config = Config(os.path.join(self.directory, ployconf)).parse()
     config.add_massager(PathMassager('global', 'foo'))
     config.add_massager(PathMassager('global', 'ham'))
     assert config == {
         'global': {
             'global': {
                 'foo': os.path.join(self.directory, 'bar', 'blubber'),
                 'ham': os.path.join(self.directory, 'egg')
             }
         }
     }
Ejemplo n.º 4
0
 def testExtendFromDifferentDirectoryWithMassager(self):
     from ploy.config import PathMassager
     os.mkdir(os.path.join(self.directory, 'bar'))
     ployconf = 'ploy.conf'
     self._write_config(
         ployconf,
         '\n'.join([
             '[global]',
             'extends = bar/foo.conf',
             'ham = egg']))
     self._write_config(
         'bar/foo.conf',
         '\n'.join([
             '[global]',
             'foo = blubber',
             'ham = pork']))
     config = Config(os.path.join(self.directory, ployconf)).parse()
     config.add_massager(PathMassager('global', 'foo'))
     config.add_massager(PathMassager('global', 'ham'))
     assert config == {
         'global': {
             'global': {
                 'foo': os.path.join(self.directory, 'bar', 'blubber'),
                 'ham': os.path.join(self.directory, 'egg')}}}
Ejemplo n.º 5
0
 def _create_config(self, contents, path=None):
     contents = StringIO(contents)
     config = Config(contents, path=path)
     config.add_massager(
         StartupScriptMassager('instance', 'startup_script'))
     return config.parse()
Ejemplo n.º 6
0
 def _create_config(self, contents, path=None):
     contents = StringIO(contents)
     config = Config(contents, path=path)
     config.add_massager(
         StartupScriptMassager('instance', 'startup_script'))
     return config.parse()