mirror of https://github.com/zulip/zulip.git
api-tests: Exclude some documented endpoints from curl tests.
Adds a set of excluded endpoints for the test of generated curl examples in the API documentation. Currently, only the `api/test-notify` endpoint is excluded since there would need to be a push notification bouncer set up to test that generated curl example.
This commit is contained in:
parent
63dd057298
commit
5051ad6ca5
|
@ -117,3 +117,4 @@
|
|||
|
||||
* [Fetch an API key (production)](/api/fetch-api-key)
|
||||
* [Fetch an API key (development only)](/api/dev-fetch-api-key)
|
||||
* [Send a test notification to mobile device(s)](/api/test-notify)
|
||||
|
|
|
@ -24,6 +24,12 @@ from zerver.openapi.curl_param_value_generators import (
|
|||
)
|
||||
from zerver.openapi.openapi import get_endpoint_from_operationid
|
||||
|
||||
UNTESTED_GENERATED_CURL_EXAMPLES = {
|
||||
# Would need push notification bouncer set up to test the
|
||||
# generated curl example for this endpoint.
|
||||
"test-notify",
|
||||
}
|
||||
|
||||
|
||||
def test_generated_curl_examples_for_success(client: Client) -> None:
|
||||
default_authentication_line = f"{client.email}:{client.api_key}"
|
||||
|
@ -42,9 +48,10 @@ def test_generated_curl_examples_for_success(client: Client) -> None:
|
|||
with open(rest_endpoints_path) as f:
|
||||
rest_endpoints_raw = f.read()
|
||||
ENDPOINT_REGEXP = re.compile(r"/api/\s*(.*?)\)")
|
||||
endpoint_list = sorted(set(re.findall(ENDPOINT_REGEXP, rest_endpoints_raw)))
|
||||
documented_endpoints = set(re.findall(ENDPOINT_REGEXP, rest_endpoints_raw))
|
||||
endpoints_to_test = sorted(documented_endpoints.difference(UNTESTED_GENERATED_CURL_EXAMPLES))
|
||||
|
||||
for endpoint in endpoint_list:
|
||||
for endpoint in endpoints_to_test:
|
||||
article_name = endpoint + ".md"
|
||||
file_name = os.path.join(settings.DEPLOY_ROOT, "api_docs/", article_name)
|
||||
|
||||
|
|
Loading…
Reference in New Issue