Skip to content

Commit

Permalink
more url variations for issue #327
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtepkeev committed Mar 9, 2024
1 parent 79ef42b commit 9aecee8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions redminelib/managers/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_resources_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9aecee8

Please sign in to comment.