When copying a ComponentDefinition "parent" that has a sub-Component "child" into a new namespace, if the definition property of "child" does not refer to a ComponentDefinition in the same document, then the copy of "child" appears to lose its definition property. As a user, I would expect the copy of "child" to retain the same definition property as the original "child". Here is some example code:
import sbol2
sbol2.Config.setOption('sbol_typed_uris', False)
sbol2.Config.setOption('validate', False)
sbol2.setHomespace('http://synbict.org')
test_doc = sbol2.Document()
parent_comp = test_doc.componentDefinitions.create('parent')
child_sub_comp = parent_comp.components.create('child')
child_sub_comp.definition = 'http://synbict.org/child/1'
sbol2.setHomespace('http://sd2e.org')
parent_comp.copy(test_doc, 'http://synbict.org', '1')
child_copy = parent_copy.components.get('http://sd2e.org/parent/child/1')
print('Should be True: ' + str(child_copy.definition is not None and child_copy.definition == 'http://synbict.org/child/1'))
Thanks for the test case. All object references that were not in the object's current document were dropped in Identified.copy(). I have added this as a unit test and fixed the bug.
When copying a ComponentDefinition "parent" that has a sub-Component "child" into a new namespace, if the definition property of "child" does not refer to a ComponentDefinition in the same document, then the copy of "child" appears to lose its definition property. As a user, I would expect the copy of "child" to retain the same definition property as the original "child". Here is some example code: