diff --git a/morphapi/api/neuromorphorg.py b/morphapi/api/neuromorphorg.py index ab672fa..403f335 100644 --- a/morphapi/api/neuromorphorg.py +++ b/morphapi/api/neuromorphorg.py @@ -41,11 +41,18 @@ def get_fields_values(self, field): """ Returns the list of allowed values for a given query field """ - return list( - request_no_ssl(self._base_url + f"/fields/{field}").json()[ - "fields" - ] - ) + current_page = 0 + max_page = 1 + values = [] + while current_page < max_page: + req = request_no_ssl( + self._base_url + + f"/fields/{field}?&size=1000&page={current_page}" + ).json() + values.extend(req["fields"]) + max_page = req.get("page", {}).get("totalPages", max_page) + current_page += 1 + return values def get_neurons_metadata(self, size=100, page=0, **criteria): """ diff --git a/tests/test_download.py b/tests/test_download.py index 9cd0a55..42ef4dd 100644 --- a/tests/test_download.py +++ b/tests/test_download.py @@ -56,6 +56,9 @@ def test_neuromorpho_download(tmpdir): assert neurons[0].data_file.name == "BAD ID.swc" assert neurons[0].points is None + # Test get_fields_values + assert len(api.get_fields_values("strain")) > 1000 + def test_mouselight_download(tmpdir): mlapi = MouseLightAPI(base_dir=tmpdir)