Skip to content

Commit

Permalink
Merge pull request #273 from SynBioDex/244-fix-remove
Browse files Browse the repository at this point in the history
244 fix remove
  • Loading branch information
tcmitchell authored Jun 3, 2020
2 parents af22a90 + 4bf0863 commit 179057d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 0 additions & 6 deletions sbol2/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,6 @@ def removeOwnedObject_int(self, index):
obj = object_store[index]
if self._sbol_owner.getTypeURI() == SBOL_DOCUMENT:
del obj.doc.SBOLObjects[rdflib.URIRef(obj.identity)]
# Erase nested, hidden TopLevel objects from Document
if obj.doc is not None and obj.doc.find(obj.identity) is not None:
obj.doc = None # TODO not sure what this does
del object_store[index]
self.validate(None)
else:
Expand All @@ -823,9 +820,6 @@ def removeOwnedObject_str(self, uri):
# Erase TopLevel objects from Document
if self._sbol_owner.getTypeURI() == SBOL_DOCUMENT:
del obj.doc.SBOLObjects[rdflib.URIRef(uri)]
# Erase nested, hidden TopLevel objects from Document
if obj.doc is not None and obj.doc.find(uri) is not None:
obj.doc = None # TODO not sure what this does
self.validate(None)
return obj

Expand Down
11 changes: 11 additions & 0 deletions test/test_componentdefinition.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,17 @@ def test_hidden_sequence(self):
rdflib.URIRef(sbol2.SBOL_SEQUENCE_PROPERTY),
rdflib.URIRef(seq.identity)))

@unittest.expectedFailure # See #272
def test_remove_hidden_sequence(self):
# Objects contained in a hidden property shouldn't persist if they are
# removed from the Document top level
doc = sbol2.Document()
cd = doc.componentDefinitions.create('cd1')
cd.sequence = sbol2.Sequence('cd1_sequence')
self.assertIn('cd1_sequence', doc.sequences)
doc.sequences.remove('cd1_sequence')
self.assertIsNone(cd.sequence)

def test_sequence_validation(self):
# sequence and sequences should be synced up
cd = sbol2.ComponentDefinition('cd1', sbol2.BIOPAX_DNA)
Expand Down

0 comments on commit 179057d

Please sign in to comment.