From 37c6f05e0f0637a92b9f5fd2868776e6c88b3e9c Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Sat, 1 Jun 2024 12:19:52 +0200 Subject: [PATCH 1/5] add test of get_histories: limit and offset --- bioblend/_tests/TestGalaxyHistories.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bioblend/_tests/TestGalaxyHistories.py b/bioblend/_tests/TestGalaxyHistories.py index 160b6eb5c..53f39ae32 100644 --- a/bioblend/_tests/TestGalaxyHistories.py +++ b/bioblend/_tests/TestGalaxyHistories.py @@ -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(others) > 0 # guess the test makes more sense with at least 2 histories + 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 From 6a1b47de0cfcd37fa390e557367835e696c5e04e Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Sat, 1 Jun 2024 12:46:44 +0200 Subject: [PATCH 2/5] fix docs for offset --- bioblend/galaxy/histories/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bioblend/galaxy/histories/__init__.py b/bioblend/galaxy/histories/__init__.py index 93e04fa47..7e817b85b 100644 --- a/bioblend/galaxy/histories/__init__.py +++ b/bioblend/galaxy/histories/__init__.py @@ -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 + at item at index offset (i.e. start with the element offset+1). :rtype: list :return: List of history dicts. From dd1dacfd20e766aa603edf0d1376ba8ef30598a2 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Sat, 1 Jun 2024 15:52:07 +0200 Subject: [PATCH 3/5] fix linter issue --- bioblend/galaxy/dataset_collections/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bioblend/galaxy/dataset_collections/__init__.py b/bioblend/galaxy/dataset_collections/__init__.py index addd84a32..e1dff9b20 100644 --- a/bioblend/galaxy/dataset_collections/__init__.py +++ b/bioblend/galaxy/dataset_collections/__init__.py @@ -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: From bc58a96acb4e1d17029f3068832d05b231c55107 Mon Sep 17 00:00:00 2001 From: M Bernt Date: Sat, 1 Jun 2024 19:43:38 +0200 Subject: [PATCH 4/5] Improved wording Co-authored-by: Nicola Soranzo --- bioblend/galaxy/histories/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bioblend/galaxy/histories/__init__.py b/bioblend/galaxy/histories/__init__.py index 7e817b85b..6efc6f204 100644 --- a/bioblend/galaxy/histories/__init__.py +++ b/bioblend/galaxy/histories/__init__.py @@ -219,7 +219,7 @@ def get_histories( :type offset: int :param offset: skip the first (offset) items and begin returning - at item at index offset (i.e. start with the element offset+1). + items at index offset (i.e. start with the element offset+1). :rtype: list :return: List of history dicts. From e37fa02b0cc0d4d00093068c66f546bd3ebe769c Mon Sep 17 00:00:00 2001 From: M Bernt Date: Sat, 1 Jun 2024 21:44:22 +0200 Subject: [PATCH 5/5] Only assume 1 history in the 2nd batch Co-authored-by: Nicola Soranzo --- bioblend/_tests/TestGalaxyHistories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bioblend/_tests/TestGalaxyHistories.py b/bioblend/_tests/TestGalaxyHistories.py index 53f39ae32..b1ae681b9 100644 --- a/bioblend/_tests/TestGalaxyHistories.py +++ b/bioblend/_tests/TestGalaxyHistories.py @@ -73,7 +73,7 @@ def test_get_histories(self): # Test limit and offset first = self.gi.histories.get_histories(limit=1) others = self.gi.histories.get_histories(offset=1) - assert len(others) > 0 # guess the test makes more sense with at least 2 histories + 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)