Ejemplo n.º 1
0
    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])
Ejemplo n.º 2
0
    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])
Ejemplo n.º 3
0
    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])
Ejemplo n.º 4
0
    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])
Ejemplo n.º 5
0
    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])
Ejemplo n.º 7
0
    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_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])
Ejemplo n.º 9
0
 def test_non_existant_file(self):
     infos = from_config_file("file_that_does_not_exists")
     self.assertEqual(0, len(infos))
Ejemplo n.º 10
0
    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))
Ejemplo n.º 11
0
 def test_non_existant_file(self):
     infos = from_config_file('file_that_does_not_exists')
     self.assertEqual(0, len(infos))
Ejemplo n.º 12
0
    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))