Mercurial > hg > configuration
diff tests/unit.py @ 102:c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 01 May 2012 10:33:37 -0700 |
parents | 0804a706d6bf |
children | a2184db43fe2 |
line wrap: on
line diff
--- a/tests/unit.py Mon Apr 30 13:21:48 2012 -0700 +++ b/tests/unit.py Tue May 01 10:33:37 2012 -0700 @@ -59,6 +59,10 @@ 'activeTests': ['ts']} example(config) config['test_timeout'] = 1200 # default + config['preferences'] = {"browser.bookmarks.max_backups": 0, + "browser.cache.disk.smart_size.enabled": False} + + # ensure they are equal self.assertEqual(config, example.config) example.serialize(filename) self.assertTrue(os.path.exists(filename)) @@ -101,6 +105,7 @@ missingvalueexception = e self.assertTrue(isinstance(e, configuration.MissingValueException)) + def test_multiple_configurations(self): """test having multiple configurations""" @@ -141,5 +146,25 @@ config['test_timeout'] = 1200 self.assertEqual(example.config, config) + def test_extend(self): + + # default preferences + example = ExampleConfiguration() + default_prefs = {"browser.bookmarks.max_backups": 0, + "browser.cache.disk.smart_size.enabled": False} + example.parse_args(['-a', 'ts', '-e', '/opt/bin/firefox']) + self.assertEqual(example.config['preferences'], default_prefs) + + # now extend them + example = ExampleConfiguration() + default_prefs['network.dns.ipv4OnlyDomains'] = 'localhost' + tf = tempfile.mktemp() + f = file(tf, 'w') + f.write(json.dumps({'preferences': {'network.dns.ipv4OnlyDomains': 'localhost'}})) + f.close() + example.parse_args(['-a', 'ts', '-e', '/opt/bin/firefox', tf]) + self.assertEqual(example.config['preferences'], default_prefs) + os.remove(tf) + if __name__ == '__main__': unittest.main()