def test_config_load_valid_config(self): config_file = tempfile.NamedTemporaryFile(mode="w") config_file.write('{"global": {"AMIs": {"some_ami": {}}}}') config_file.file.close() AUConfig.load(config_file.name) config_file.close() self.assertEqual({"some_ami"}, AUConfig.codenames)
def test_config_update_filter(self): AUConfig.raw_dict = {"global": {"AMIs": {"some_ami": {}}}} AUConfig.update_filter({"some__other_ami": {}}) self.assertEqual( {"global": {"AMIs": {"some__other_ami": {}, "some_ami": {}}}}, AUConfig.raw_dict, )
def test_config_load_invalid_config(self): # invalid, but yaml is valid config_file = tempfile.NamedTemporaryFile(mode="w") config_file.write('{"this-is-invalid": 1}') config_file.file.close() with self.assertRaises(AMIUpdaterFatalException): AUConfig.load(config_file.name) config_file.close() # invalid, but yaml is valid config_file = tempfile.NamedTemporaryFile(mode="w") config_file.write('{"this-is-totally-invalid": 1') config_file.file.close() with self.assertRaises(AMIUpdaterFatalException): AUConfig.load(config_file.name) config_file.close()