Skip to content

Commit

Permalink
Merge pull request #486 from bernt-matthias/doc_and_test_limit
Browse files Browse the repository at this point in the history
Fix docs for `offset` in `get_histories` and add test
  • Loading branch information
nsoranzo committed Jun 2, 2024
2 parents a11a57f + e37fa02 commit 91f2344
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions bioblend/_tests/TestGalaxyHistories.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ def test_get_histories(self):
all_histories = self.gi.histories.get_histories()
assert len(all_histories) > 0

# Test limit and offset
first = self.gi.histories.get_histories(limit=1)
others = self.gi.histories.get_histories(offset=1)
assert len(first) == 1
assert [h["id"] for h in all_histories] == [h["id"] for h in first] + [h["id"] for h in others]

out_of_limit = self.gi.histories.get_histories(offset=1000000)
assert out_of_limit == []

# Check whether id is present, when searched by name
histories = self.gi.histories.get_histories(name=self.default_history_name)
assert len([h for h in histories if h["id"] == self.history["id"]]) == 1
Expand Down
2 changes: 1 addition & 1 deletion bioblend/galaxy/dataset_collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(
self.name = name
self.type = type
if isinstance(elements, dict):
self.elements: List[Union["CollectionElement", "SimpleElement"]] = [
self.elements: List[Union[CollectionElement, SimpleElement]] = [
HistoryDatasetElement(name=key, id=value) for key, value in elements.values()
]
elif elements:
Expand Down
4 changes: 2 additions & 2 deletions bioblend/galaxy/histories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ def get_histories(
:param limit: How many items to return (upper bound).
:type offset: int
:param offset: skip the first ( offset - 1 ) items and begin returning
at the Nth item.
:param offset: skip the first (offset) items and begin returning
items at index offset (i.e. start with the element offset+1).
:rtype: list
:return: List of history dicts.
Expand Down

0 comments on commit 91f2344

Please sign in to comment.