api: add support for description of put endpoints (#53480)
This commit is contained in:
parent
3231dd358f
commit
0114f77618
|
@ -39,11 +39,13 @@ class endpoint(object):
|
|||
wrap_response=False,
|
||||
description=None,
|
||||
description_get=None,
|
||||
description_put=None,
|
||||
description_post=None,
|
||||
description_patch=None,
|
||||
description_delete=None,
|
||||
long_description=None,
|
||||
long_description_get=None,
|
||||
long_description_put=None,
|
||||
long_description_post=None,
|
||||
long_description_patch=None,
|
||||
long_description_delete=None,
|
||||
|
@ -66,12 +68,14 @@ class endpoint(object):
|
|||
self.wrap_response = wrap_response
|
||||
self.descriptions = {
|
||||
'get': description_get or description,
|
||||
'put': description_put or description,
|
||||
'post': description_post or description,
|
||||
'patch': description_patch or description,
|
||||
'delete': description_delete or description,
|
||||
}
|
||||
self.long_descriptions = {
|
||||
'get': long_description_get or long_description,
|
||||
'put': long_description_put or long_description,
|
||||
'post': long_description_post or long_description,
|
||||
'patch': long_description_patch or long_description,
|
||||
'delete': long_description_delete or long_description,
|
||||
|
|
|
@ -217,11 +217,21 @@ class FakeConnectorBase(object):
|
|||
def foo6(self, request, param1, param2='a'):
|
||||
pass
|
||||
|
||||
@endpoint(description_get='foo7 get', description_post='foo7 post', methods=['get', 'post'])
|
||||
@endpoint(
|
||||
description_get='foo7 get',
|
||||
description_post='foo7 post',
|
||||
description_put='foo7 put',
|
||||
methods=['get', 'post', 'put'],
|
||||
)
|
||||
def foo7(self, request, param1='a', param2='b', param3='c'):
|
||||
pass
|
||||
|
||||
@endpoint(long_description_get='foo7 get', long_description_post='foo7 post', methods=['get', 'post'])
|
||||
@endpoint(
|
||||
long_description_get='foo7 get',
|
||||
long_description_post='foo7 post',
|
||||
long_description_put='foo7 put',
|
||||
methods=['get', 'post', 'put'],
|
||||
)
|
||||
def foo7b(self, request, param1='a', param2='b', param3='c'):
|
||||
pass
|
||||
|
||||
|
@ -300,12 +310,16 @@ def test_endpoint_decorator():
|
|||
connector.foo7.endpoint_info.http_method = 'post'
|
||||
assert connector.foo7.endpoint_info.description == 'foo7 post'
|
||||
assert connector.foo7.endpoint_info.cache_duration is None
|
||||
connector.foo7.endpoint_info.http_method = 'put'
|
||||
assert connector.foo7.endpoint_info.description == 'foo7 put'
|
||||
|
||||
connector.foo7b.endpoint_info.http_method = 'get'
|
||||
assert connector.foo7b.endpoint_info.long_description == 'foo7 get'
|
||||
connector.foo7b.endpoint_info.http_method = 'post'
|
||||
assert connector.foo7b.endpoint_info.long_description == 'foo7 post'
|
||||
assert connector.foo7b.endpoint_info.cache_duration is None
|
||||
connector.foo7b.endpoint_info.http_method = 'put'
|
||||
assert connector.foo7b.endpoint_info.long_description == 'foo7 put'
|
||||
|
||||
assert connector.cached_endpoint.endpoint_info.cache_duration == 10
|
||||
|
||||
|
|
Loading…
Reference in New Issue