def test_it_sets_options_from_an_json_file(self): contents = """ { "a" : "stuff" , "b" : "things" } """ with a_temp_file(contents) as filename: config_util = ConfigUtil() config_util.values |should| equal_to({}) config_util.apply_config_file(filename) config_util.values |should| equal_to({"a":"stuff", "b":"things"})
def test_it_doesnt_override_existing_non_default_values(self): contents = """ { "a" : "stuff" , "b" : "things" , "c" : "and" , "d" : "shells" , "e-f" : "blah" , "g-h" : "other" } """ with a_temp_file(contents) as filename: config_util = ConfigUtil() c_val = Default(21) config_util.use_options({'b':21, 'c':c_val, 'd':None, "g-h":"meh"}) config_util.values |should| equal_to({'b':21, 'c':c_val, 'd':None, "g_h":"meh"}) config_util.apply_config_file(filename) config_util.values |should| equal_to({"a":"stuff", "b":21, "c":"and", 'd':None, "e_f":"blah", "g_h":"meh"})