You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2024/05/02 17:15:51 UTC
(allura) 01/03: [#8559] simplify some api test setup
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8559
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 6ce8224395c3aa699a25aefd089dcfddbfb7777e
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Thu May 2 11:38:57 2024 -0400
[#8559] simplify some api test setup
---
AlluraTest/alluratest/controller.py | 16 +++++++---------
ForgeTracker/forgetracker/tests/functional/test_rest.py | 17 +++++++----------
2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/AlluraTest/alluratest/controller.py b/AlluraTest/alluratest/controller.py
index 82d72a569..a7f7b3d81 100644
--- a/AlluraTest/alluratest/controller.py
+++ b/AlluraTest/alluratest/controller.py
@@ -252,15 +252,13 @@ class TestRestApiBase(TestController):
return self._token_cache[username]
- def _api_call(self, method, path, wrap_args=None, user='test-admin', status=None, **params):
+ def _api_call(self, method, path, user='test-admin', status=None, **params):
'''
If you need to use one of the method kwargs as a URL parameter,
pass params={...} as a dict instead of **kwargs
'''
if 'params' in params:
params = params['params']
- if wrap_args:
- params = {wrap_args: params}
if status is None:
status = [200, 201, 301, 302]
if not isinstance(params, str):
@@ -283,14 +281,14 @@ class TestRestApiBase(TestController):
else:
return response
- def api_get(self, path, wrap_args=None, user='test-admin', status=None, **params):
- return self._api_call('GET', path, wrap_args, user, status, **params)
+ def api_get(self, path, user='test-admin', status=None, **params):
+ return self._api_call('GET', path, user, status, **params)
- def api_post(self, path, wrap_args=None, user='test-admin', status=None, **params):
- return self._api_call('POST', path, wrap_args, user, status, **params)
+ def api_post(self, path, user='test-admin', status=None, **params):
+ return self._api_call('POST', path, user, status, **params)
- def api_delete(self, path, wrap_args=None, user='test-admin', status=None, **params):
- return self._api_call('DELETE', path, wrap_args, user, status, **params)
+ def api_delete(self, path, user='test-admin', status=None, **params):
+ return self._api_call('DELETE', path, user, status, **params)
def oauth1_webtest(url: str, oauth_kwargs: dict, method='GET') -> tuple[str, dict, dict, dict]:
diff --git a/ForgeTracker/forgetracker/tests/functional/test_rest.py b/ForgeTracker/forgetracker/tests/functional/test_rest.py
index 85cfc77eb..54531aa4e 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_rest.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_rest.py
@@ -44,14 +44,13 @@ class TestTrackerApiBase(TestRestApiBase):
def create_ticket(self, summary=None, status=None):
return self.api_post(
'/rest/p/test/bugs/new',
- wrap_args='ticket_form',
- params=dict(
+ params=dict(ticket_form=dict(
summary=summary or 'test new ticket',
status=self.tracker_globals.open_status_names.split()[0],
labels='',
description='',
assigned_to='',
- **{'custom_fields._milestone': ''}),
+ **{'custom_fields._milestone': ''})),
status=status)
@@ -61,15 +60,14 @@ class TestRestNewTicket(TestTrackerApiBase):
summary = 'test new ticket'
ticket_view = self.api_post(
'/rest/p/test/bugs/new',
- wrap_args='ticket_form',
- params=dict(
+ params=dict(ticket_form=dict(
summary=summary,
status=self.tracker_globals.open_status_names.split()[0],
labels='foo,bar',
description='descr',
assigned_to='',
**{'custom_fields._milestone': ''}
- ))
+ )))
json = ticket_view.json['ticket']
assert json['status'] == 'open', json
assert json['summary'] == 'test new ticket', json
@@ -112,8 +110,7 @@ class TestRestUpdateTicket(TestTrackerApiBase):
del args[bad_key]
args['private'] = str(args['private'])
args['discussion_disabled'] = str(args['discussion_disabled'])
- ticket_view = self.api_post(
- '/rest/p/test/bugs/1/save', wrap_args='ticket_form', params=h.encode_keys(args))
+ ticket_view = self.api_post('/rest/p/test/bugs/1/save', params={'ticket_form': args})
assert ticket_view.status_int == 200, ticket_view.showbrowser()
json = ticket_view.json['ticket']
assert int(json['ticket_num']) == 1
@@ -177,14 +174,14 @@ class TestRestDiscussion(TestTrackerApiBase):
thread_id = r.json['ticket']['discussion_thread']['_id']
post = self.api_post(
'/rest/p/test/bugs/_discuss/thread/%s/new' % thread_id,
- text='This is a comment', wrap_args=None)
+ text='This is a comment')
thread = self.api_get('/rest/p/test/bugs/_discuss/thread/%s/' % thread_id)
assert len(thread.json['thread']['posts']) == 1, thread.json
assert post.json['post']['text'] == 'This is a comment', post.json
reply = self.api_post(
'/rest/p/test/bugs/_discuss/thread/{}/{}/reply'.format(thread.json['thread']
['_id'], post.json['post']['slug']),
- text='This is a reply', wrap_args=None)
+ text='This is a reply')
assert reply.json['post']['text'] == 'This is a reply', reply.json
thread = self.api_get('/rest/p/test/bugs/_discuss/thread/%s/' % thread_id)
assert len(thread.json['thread']['posts']) == 2, thread.json