mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
Fixes #2665. Regenerated by tabbott with `lint --fix` after a rebase and change in parameters. Note from tabbott: In a few cases, this converts technical debt in the form of unsorted imports into different technical debt in the form of our largest files having very long, ugly import sequences at the start. I expect this change will increase pressure for us to split those files, which isn't a bad thing. Signed-off-by: Anders Kaseorg <anders@zulip.com>
29 lines
950 B
Python
29 lines
950 B
Python
import json
|
|
import os
|
|
import subprocess
|
|
|
|
from zulip import Client
|
|
|
|
from zerver.openapi.openapi import validate_against_openapi_schema
|
|
|
|
|
|
def test_js_bindings(client: Client) -> None:
|
|
os.environ['ZULIP_USERNAME'] = client.email
|
|
os.environ['ZULIP_API_KEY'] = client.api_key
|
|
os.environ['ZULIP_REALM'] = client.base_url[:-5]
|
|
|
|
output = subprocess.check_output(
|
|
args=['node', 'zerver/openapi/javascript_examples.js'],
|
|
universal_newlines=True,
|
|
)
|
|
endpoint_responses = json.loads(output)
|
|
|
|
for response_data in endpoint_responses:
|
|
print(f"Testing javascript example: {response_data['name']} ...")
|
|
validate_against_openapi_schema(response_data['result'],
|
|
response_data['endpoint'],
|
|
response_data['method'],
|
|
response_data['status_code'])
|
|
|
|
print('JavaScript examples validated.')
|