Skip to content

Commit 9c3b484

Browse files
d-w-moorealanking
authored andcommitted
[#571] exclude collection "/" from subcollections
"/" by definition cannot be a proper subcollection of any other collection.
1 parent d475679 commit 9c3b484

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

irods/collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def metadata(self):
5050
def subcollections(self):
5151
query = self.manager.sess.query(Collection)\
5252
.filter(Collection.parent_name == self.path)
53-
return [iRODSCollection(self.manager, row) for row in query]
53+
return [iRODSCollection(self.manager, row) for row in query if row[Collection.name] != '/']
5454

5555
@property
5656
def data_objects(self):

irods/test/collection_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,15 @@ def test_touch_operation_ignores_unsupported_options__525(self):
489489
if collection:
490490
user_session.collections.remove(path, recurse=True, force=True)
491491

492+
def test_subcollections_member_excludes_root_collection__571(self):
493+
494+
root_coll = self.sess.collections.get("/")
495+
496+
# Assert that none of the root collection's immediate children (as listed in the object's
497+
# 'subcollections' property) point to the root subcollection.
498+
self.assertEqual(root_coll.path, "/")
499+
self.assertEqual([], [_ for _ in root_coll.subcollections if _.path == "/"])
500+
492501

493502
if __name__ == "__main__":
494503
# let the tests find the parent irods lib

0 commit comments

Comments
 (0)