def testOverrides(self): contents = StringIO("\n".join([ "[section]", "value=1"])) config = Config(contents).parse() self.assertDictEqual( config, {'global': {'section': {'value': '1'}}}) self.assertDictEqual( config.get_section_with_overrides( 'global', 'section', overrides=None), {'value': '1'}) self.assertDictEqual( config.get_section_with_overrides( 'global', 'section', overrides={'value': '2'}), {'value': '2'}) self.assertDictEqual( config.get_section_with_overrides( 'global', 'section', overrides={'value2': '2'}), {'value': '1', 'value2': '2'}) # make sure nothing is changed afterwards self.assertDictEqual( config, {'global': {'section': {'value': '1'}}})
def testMassagedOverrides(self): from mr.awsome.config import IntegerMassager dummyplugin.massagers.append(IntegerMassager('global', 'value')) dummyplugin.massagers.append(IntegerMassager('global', 'value2')) contents = StringIO("\n".join([ self.plugin_config, "[section]", "value=1"])) config = Config(contents).parse() self.assertDictEqual( config['global'], {'section': {'value': 1}}) self.assertDictEqual( config.get_section_with_overrides( 'global', 'section', overrides=None), {'value': 1}) self.assertDictEqual( config.get_section_with_overrides( 'global', 'section', overrides={'value': '2'}), {'value': 2}) self.assertDictEqual( config.get_section_with_overrides( 'global', 'section', overrides={'value2': '2'}), {'value': 1, 'value2': 2}) # make sure nothing is changed afterwards self.assertDictEqual( config['global'], {'section': {'value': 1}})