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."
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."
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') } } }
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')}}}
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()