Mercurial > hg > configuration
changeset 28:c516ab813079
begin stubbing serialization/deserialization
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 26 Mar 2012 16:54:37 -0700 |
parents | c6d966431498 |
children | fadcc6ab51d4 |
files | configuration/config.py tests/unit.py |
diffstat | 2 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/configuration/config.py Mon Mar 26 16:40:35 2012 -0700 +++ b/configuration/config.py Mon Mar 26 16:54:37 2012 -0700 @@ -251,3 +251,21 @@ # return parsed arguments return options, args + + ### serialization/deserialization + + def configuration_provider(self, format): + """configuration provider guess for a given filename""" + for provider in self.configuration_providers: + if format in provider.extensions: + return provider + + def serialize(self, filename, format=None): + """serialize configuration to a file""" + + def deserialize(self, filename, format=None): + """load configuration from a file""" + + extension = os.path.splitext(filename)[-1] + if not extension: + return None
--- a/tests/unit.py Mon Mar 26 16:40:35 2012 -0700 +++ b/tests/unit.py Mon Mar 26 16:54:37 2012 -0700 @@ -16,6 +16,8 @@ class ConfigurationUnitTest(unittest.TestCase): def test_cli(self): + """test command line interface""" + example = ExampleConfiguration() # parse command line arguments @@ -32,6 +34,9 @@ self.assertEqual(example.config['activeTests'], ['ts']) self.assertEqual(example.config['browser_path'], '/home/jhammel/bin/firefox') + def test_configuration_providers(self): + """test file-based configuration providers""" + if __name__ == '__main__': unittest.main()