Skip to content

Commit

Permalink
Migrate doctests to unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Dec 21, 2024
1 parent 856061d commit 56d4635
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 27 deletions.
28 changes: 1 addition & 27 deletions lib/galaxy/model/dataset_collections/type_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,7 @@ def for_collection_type(self, collection_type, fields=None):

class CollectionTypeDescription:
"""Abstraction over dataset collection type that ties together string
reprentation in database/model with type registry.
>>> factory = CollectionTypeDescriptionFactory(None)
>>> nested_type_description = factory.for_collection_type("list:paired")
>>> paired_type_description = factory.for_collection_type("paired")
>>> nested_type_description.has_subcollections_of_type("list")
False
>>> nested_type_description.has_subcollections_of_type("list:paired")
False
>>> nested_type_description.has_subcollections_of_type("paired")
True
>>> nested_type_description.has_subcollections_of_type(paired_type_description)
True
>>> nested_type_description.has_subcollections()
True
>>> paired_type_description.has_subcollections()
False
>>> paired_type_description.rank_collection_type()
'paired'
>>> nested_type_description.rank_collection_type()
'list'
>>> nested_type_description.effective_collection_type(paired_type_description)
'list'
>>> nested_type_description.effective_collection_type_description(paired_type_description).collection_type
'list'
>>> nested_type_description.child_collection_type()
'paired'
representation in database/model with type registry.
"""

collection_type: str
Expand Down
18 changes: 18 additions & 0 deletions test/unit/data/dataset_collections/test_type_descriptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from galaxy.model.dataset_collections.type_description import CollectionTypeDescriptionFactory


def test_simple_descriptions():
factory = CollectionTypeDescriptionFactory(None)
nested_type_description = factory.for_collection_type("list:paired")
paired_type_description = factory.for_collection_type("paired")
assert not nested_type_description.has_subcollections_of_type("list")
assert not nested_type_description.has_subcollections_of_type("list:paired")
assert nested_type_description.has_subcollections_of_type("paired")
assert nested_type_description.has_subcollections_of_type(paired_type_description)
assert nested_type_description.has_subcollections()
assert not paired_type_description.has_subcollections()
assert paired_type_description.rank_collection_type() == 'paired'
assert nested_type_description.rank_collection_type() == 'list'
assert nested_type_description.effective_collection_type(paired_type_description) == 'list'
assert nested_type_description.effective_collection_type_description(paired_type_description).collection_type == 'list'
assert nested_type_description.child_collection_type() == 'paired'

0 comments on commit 56d4635

Please sign in to comment.