realm/playground: Add API endpoint for creating playground entry.

This endpoint will allow clients to create a playground entry
containing the name, pygments language and url_prefix for the
playground of their choice.

Introduced the `do_*` function in-charge of creating the entry in
the model. Handling the process of sending events which will be
done in a follow up commit.

Added the openAPI format data to zulip.yaml for POST
/realm/playgrounds. Also added python and curl examples for using
the endpoint in its markdown documented (add-playground.md).

Tests added.
This commit is contained in:
Sumanth V Rao
2020-10-27 06:44:56 +05:30
parent 40228972b9
commit 251b415987
9 changed files with 269 additions and 1 deletions

View File

@@ -380,6 +380,22 @@ def remove_realm_filter(client: Client) -> None:
validate_against_openapi_schema(result, "/realm/filters/{filter_id}", "delete", "200")
@openapi_test_function("/realm/playgrounds:post")
def add_realm_playground(client: Client) -> None:
# {code_example|start}
# Add a realm playground for Python
request = {
"name": "Python playground",
"pygments_language": json.dumps("Python"),
"url_prefix": json.dumps("https://python.example.com"),
}
result = client.call_endpoint(url="/realm/playgrounds", method="POST", request=request)
# {code_example|end}
validate_against_openapi_schema(result, "/realm/playgrounds", "post", "200")
@openapi_test_function("/users/me:get")
def get_profile(client: Client) -> None:
@@ -1417,6 +1433,7 @@ def test_server_organizations(client: Client) -> None:
get_realm_filters(client)
add_realm_filter(client)
add_realm_playground(client)
get_server_settings(client)
remove_realm_filter(client)
get_realm_emoji(client)