def test_one_component(self): name = self.make_temp_file({"csdms.cmi.component_name": _VALID_PARAMS}) infos = from_config_file(name) self.assertEqual(1, len(infos)) self.assertTrue("component_name" in infos) for key in _VALID_PARSED_PARAMS: self.assertEqual(_VALID_PARSED_PARAMS[key], infos["component_name"][key])
def test_one_component(self): name = self.make_temp_file({'csdms.cmi.component_name': _VALID_PARAMS}) infos = from_config_file(name) self.assertEqual(1, len(infos)) self.assertTrue('component_name' in infos) for key in _VALID_PARSED_PARAMS: self.assertEqual(_VALID_PARSED_PARAMS[key], infos['component_name'][key])
def test_two_components(self): params = _VALID_PARAMS name = self.make_temp_file( {"csdms.cmi.one_component": params, "csdms.cmi.another_component": params} ) infos = from_config_file(name) self.assertEqual(2, len(infos)) self.assertSetEqual(set(["one_component", "another_component"]), set(infos)) for info in infos.values(): for key in _VALID_PARSED_PARAMS: self.assertEqual(_VALID_PARSED_PARAMS[key], info[key])
def test_repeated_component_in_two_files(self): new_params = _VALID_PARAMS.copy() new_params["config_xml_file"] = "config-new.cfg" filenames = [ self.make_temp_file({"csdms.cmi.component_name": new_params}), self.make_temp_file({"csdms.cmi.component_name": _VALID_PARAMS}), ] infos = from_config_file(filenames) self.assertEqual(1, len(infos)) self.assertTrue("component_name" in infos) self.assertEqual("config.xml", infos["component_name"]["config_xml_file"]) for key in _VALID_PARSED_PARAMS: self.assertEqual(_VALID_PARSED_PARAMS[key], infos["component_name"][key])
def test_two_files(self): params = _VALID_PARAMS filenames = [ self.make_temp_file({'csdms.cmi.one_component': params}), self.make_temp_file({'csdms.cmi.another_component': params}), ] infos = from_config_file(filenames) self.assertEqual(2, len(infos)) self.assertSetEqual(set(['one_component', 'another_component']), set(infos)) for info in infos.values(): for key in _VALID_PARSED_PARAMS: self.assertEqual(_VALID_PARSED_PARAMS[key], info[key])
def test_two_components(self): params = _VALID_PARAMS name = self.make_temp_file({ "csdms.cmi.one_component": params, "csdms.cmi.another_component": params }) infos = from_config_file(name) self.assertEqual(2, len(infos)) self.assertSetEqual(set(["one_component", "another_component"]), set(infos)) for info in infos.values(): for key in _VALID_PARSED_PARAMS: self.assertEqual(_VALID_PARSED_PARAMS[key], info[key])
def test_repeated_component_in_two_files(self): new_params = _VALID_PARAMS.copy() new_params['config_xml_file'] = 'config-new.cfg' filenames = [ self.make_temp_file({'csdms.cmi.component_name': new_params}), self.make_temp_file({'csdms.cmi.component_name': _VALID_PARAMS}), ] infos = from_config_file(filenames) self.assertEqual(1, len(infos)) self.assertTrue('component_name' in infos) self.assertEqual('config.xml', infos['component_name']['config_xml_file']) for key in _VALID_PARSED_PARAMS: self.assertEqual(_VALID_PARSED_PARAMS[key], infos['component_name'][key])
def test_non_existant_file(self): infos = from_config_file("file_that_does_not_exists") self.assertEqual(0, len(infos))
def test_no_components(self): name = self.make_temp_file({"bad.section.name": _VALID_PARAMS}) infos = from_config_file(name) self.assertEqual(0, len(infos))
def test_non_existant_file(self): infos = from_config_file('file_that_does_not_exists') self.assertEqual(0, len(infos))
def test_no_components(self): name = self.make_temp_file({'bad.section.name': _VALID_PARAMS}) infos = from_config_file(name) self.assertEqual(0, len(infos))