mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 18:06:44 +00:00
test-openapi: Add coverage for documented fetch API key endpoints.
Previoulsy, test_openapi_arguments had assumed that an endpoint not using rest_dispatch used the GET method for the request. This was not the case for the "/fetch_api_key" and "/dev_fetch_api_key" endpoints, which is why those endpoints were marked as pending even though they were documented in `zerver/openapi/zulip.yaml`. Updates test_openapi_arguments to check a set of endpoints that are documented and don't use the GET method so that these endpoints can be tested and removed from the pending_endpoints set.
This commit is contained in:
committed by
Tim Abbott
parent
673e98e982
commit
571bd16ba4
@@ -235,10 +235,6 @@ class OpenAPIArgumentsTest(ZulipTestCase):
|
|||||||
# section of the same page.
|
# section of the same page.
|
||||||
"/users/me/subscriptions/{stream_id}",
|
"/users/me/subscriptions/{stream_id}",
|
||||||
#### Mobile-app only endpoints; important for mobile developers.
|
#### Mobile-app only endpoints; important for mobile developers.
|
||||||
# Mobile interface for fetching API keys
|
|
||||||
"/fetch_api_key",
|
|
||||||
# Already documented; need to fix tracking bug
|
|
||||||
"/dev_fetch_api_key",
|
|
||||||
# Mobile interface for development environment login
|
# Mobile interface for development environment login
|
||||||
"/dev_list_users",
|
"/dev_list_users",
|
||||||
# Registration for iOS/Android mobile push notifications.
|
# Registration for iOS/Android mobile push notifications.
|
||||||
@@ -279,6 +275,13 @@ class OpenAPIArgumentsTest(ZulipTestCase):
|
|||||||
"/jwt/fetch_api_key",
|
"/jwt/fetch_api_key",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Endpoints in the API documentation that don't use rest_dispatch
|
||||||
|
# and only use the POST method; used in test_openapi_arguments.
|
||||||
|
documented_post_only_endpoints = {
|
||||||
|
"fetch_api_key",
|
||||||
|
"dev_fetch_api_key",
|
||||||
|
}
|
||||||
|
|
||||||
# Endpoints where the documentation is currently failing our
|
# Endpoints where the documentation is currently failing our
|
||||||
# consistency tests. We aim to keep this list empty.
|
# consistency tests. We aim to keep this list empty.
|
||||||
buggy_documentation_endpoints: Set[str] = set()
|
buggy_documentation_endpoints: Set[str] = set()
|
||||||
@@ -585,11 +588,13 @@ so maybe we shouldn't include it in pending_endpoints.
|
|||||||
# for those using the rest_dispatch decorator; we then parse
|
# for those using the rest_dispatch decorator; we then parse
|
||||||
# its mapping of (HTTP_METHOD -> FUNCTION).
|
# its mapping of (HTTP_METHOD -> FUNCTION).
|
||||||
for p in urlconf.v1_api_and_json_patterns + urlconf.v1_api_mobile_patterns:
|
for p in urlconf.v1_api_and_json_patterns + urlconf.v1_api_mobile_patterns:
|
||||||
|
methods_endpoints: Dict[str, Any] = {}
|
||||||
if p.callback is not rest_dispatch:
|
if p.callback is not rest_dispatch:
|
||||||
# Endpoints not using rest_dispatch don't have extra data.
|
# Endpoints not using rest_dispatch don't have extra data.
|
||||||
methods_endpoints: Dict[str, Any] = dict(
|
if str(p.pattern) in self.documented_post_only_endpoints:
|
||||||
GET=p.callback,
|
methods_endpoints = dict(POST=p.callback)
|
||||||
)
|
else:
|
||||||
|
methods_endpoints = dict(GET=p.callback)
|
||||||
else:
|
else:
|
||||||
methods_endpoints = assert_is_not_none(p.default_args)
|
methods_endpoints = assert_is_not_none(p.default_args)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user