diff --git a/pyneuroml/utils/components.py b/pyneuroml/utils/components.py index ff233be5..a6f9d51a 100644 --- a/pyneuroml/utils/components.py +++ b/pyneuroml/utils/components.py @@ -19,7 +19,6 @@ def add_new_component( - nmldoc: NeuroMLDocument, component_id: str, component_type: str, component_filename: Optional[str] = None, @@ -52,8 +51,8 @@ def add_new_component( the component in :type component_filename: str :param **kwargs: parameters to pass to the Component - :returns: the Component Object - :rtype: Component + :returns: the Component Object, and the name of the XML file it was serialised in + :rtype: tuple(Component, str) """ newmodel = Model() newcomp = Component(id_=component_id, type_=component_type, **kwargs) @@ -70,6 +69,8 @@ def add_new_component( logger.info( "Component file included in NeuroML document. Note that new components will not validate against the NeuroML schema." ) - nmldoc.add(IncludeType, href=component_filename) + logger.info( + f"Please also remember to include {component_filename} in the LEMS simulation file" + ) - return newcomp + return newcomp, component_filename diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py index ca933b02..ecb255d5 100644 --- a/tests/utils/test_utils.py +++ b/tests/utils/test_utils.py @@ -287,11 +287,9 @@ def test_translate_cell_to_coords(self): def test_adding_new_components(self): """Test add_new_component method.""" - newdoc = neuroml.utils.component_factory("NeuroMLDocument", id="test_doc") # type: neuroml.NeuroMLDocument - new_comp = add_new_component( - newdoc, "newcomp", "sometype", param1="5v", param2="something" + new_comp, new_comp_file = add_new_component( + "newcomp", "sometype", param1="5v", param2="something" ) self.assertIsNotNone(new_comp) - self.assertEqual(1, len(newdoc.includes)) - self.assertIsFile("component_newcomp.xml") - os.unlink("component_newcomp.xml") + self.assertIsFile(new_comp_file) + os.unlink(new_comp_file)