From 9aecee838273f9020d100f5331e6361924690f8f Mon Sep 17 00:00:00 2001 From: Max Tepkeev Date: Sat, 9 Mar 2024 14:10:41 +0300 Subject: [PATCH] more url variations for issue #327 --- redminelib/managers/standard.py | 12 ++++++++++++ tests/test_resources_standard.py | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/redminelib/managers/standard.py b/redminelib/managers/standard.py index afc9508..7dc61a4 100644 --- a/redminelib/managers/standard.py +++ b/redminelib/managers/standard.py @@ -64,6 +64,18 @@ def _check_custom_url(path): def _construct_get_url(self, path): return super()._construct_get_url(self._check_custom_url(path)) + def all(self, **params): + resourceset = super().all(**params) + + if self.redmine.ver is not None: # https://www.redmine.org/issues/32090#note-6 + if self.redmine.ver >= (5, 1, 2): + resourceset.manager.url = f'{resourceset.manager.url}*' + elif self.redmine.ver in ((5, 1, 0), (5, 1, 1)): + resourceset.manager.url = (f'{resourceset.manager.url[:-7]}f[]=status_id&' + f'op[status_id]==&v[status_id][]=1&v[status_id][]=2&v[status_id][]=3') + + return resourceset + def _prepare_create_request(self, request): request = super()._prepare_create_request(request) request['send_information'] = request[self.container].pop('send_information', False) diff --git a/tests/test_resources_standard.py b/tests/test_resources_standard.py index ee87d34..d77b248 100644 --- a/tests/test_resources_standard.py +++ b/tests/test_resources_standard.py @@ -1351,6 +1351,15 @@ def test_user_all(self): self.assertEqual(users[1].id, 2) self.assertEqual(users[1].firstname, 'Jack') + def test_user_all_url_variations(self): + self.redmine.ver = (5, 0, 0) + self.assertEqual(self.redmine.user.all().manager.url, f'{self.url}/users.json?status=') + self.redmine.ver = (5, 1, 0) + self.assertEqual(self.redmine.user.all().manager.url, f'{self.url}/users.json?f[]=status_id&' + f'op[status_id]==&v[status_id][]=1&v[status_id][]=2&v[status_id][]=3') + self.redmine.ver = (6, 0, 0) + self.assertEqual(self.redmine.user.all().manager.url, f'{self.url}/users.json?status=*') + def test_user_filter(self): self.response.json.return_value = responses['user']['filter'] users = self.redmine.user.filter(status_id=2)