Mercurial > hg > configuration
comparison tests/unit.py @ 55:87bd539a21d3
test with overrides
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 27 Mar 2012 14:55:29 -0700 |
parents | 09fbc09455d4 |
children | 7f8e9c5d1606 |
comparison
equal
deleted
inserted
replaced
54:135322cc5bc0 | 55:87bd539a21d3 |
---|---|
99 self.assertTrue(isinstance(e, configuration.MissingValueException)) | 99 self.assertTrue(isinstance(e, configuration.MissingValueException)) |
100 | 100 |
101 def test_multiple_configurations(self): | 101 def test_multiple_configurations(self): |
102 """test having multiple configurations""" | 102 """test having multiple configurations""" |
103 | 103 |
104 example = ExampleConfiguration() | |
105 | |
106 # simple override | 104 # simple override |
107 config1 = {'browser_path': '/home/jhammel/bin/firefox', | |
108 'activeTests': ['ts']} | |
109 args1 = ['-e', '/opt/bin/firefox'] | 105 args1 = ['-e', '/opt/bin/firefox'] |
110 | 106 |
111 # | 107 # simple serialized file |
108 json_file = os.path.join(here, 'base.json') | |
109 assert os.path.exists(json_file) | |
110 json_config = json.loads(file(json_file).read()) | |
111 | |
112 # parse the json file | |
113 example = ExampleConfiguration() | |
114 example.parse([json_file]) | |
115 self.assertEqual(example.config, json_config) | |
116 | |
117 # parse the json file with overrides | |
118 example = ExampleConfiguration() | |
119 example.parse([json_file] + args1) | |
120 config = json_config.copy() | |
121 config['browser_path'] = '/opt/bin/firefox' | |
122 self.assertEqual(example.config, config) | |
112 | 123 |
113 if __name__ == '__main__': | 124 if __name__ == '__main__': |
114 unittest.main() | 125 unittest.main() |