Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

api docs: Move stray get_events Python example.

Suyash Vardhan Mathuracb1244f939c
diff --git a/templates/zerver/api/get-events.md b/templates/zerver/api/get-events.md
index 2549f8ed3b8..728ec054f3f 100644
--- a/templates/zerver/api/get-events.md
+++ b/templates/zerver/api/get-events.md
@@ -7,26 +7,7 @@
{start_tabs}
{tab|python}
-```
-#!/usr/bin/env python
-
-import sys
-import zulip
-
-# Pass the path to your zuliprc file here.
-client = zulip.Client(config_file="~/zuliprc")
-
-# If you already have a queue registered and thus, have a queue_id
-# on hand, you may use client.get_events() and pass in the above
-# parameters, like so:
-print(client.get_events(
- queue_id="1515010080:4",
- last_event_id=-1
-))
-```
-
-`call_on_each_message` and `call_on_each_event` will automatically register
-a queue for you.
+{generate_code_example(python)|/events:get|example}
{generate_code_example(javascript)|/events:get|example}
diff --git a/zerver/openapi/python_examples.py b/zerver/openapi/python_examples.py
index b91df29daf6..49321c47e48 100644
--- a/zerver/openapi/python_examples.py
+++ b/zerver/openapi/python_examples.py
@@ -1097,6 +1097,18 @@ def deregister_queue(client: Client, queue_id: str) -> None:
validate_against_openapi_schema(result, "/events", "delete", "400")
+@openapi_test_function("/events:get")
+def get_queue(client: Client, queue_id: str) -> None:
+
+ # {code_example|start}
+ # If you already have a queue registered and thus, have a queue_id
+ # on hand, you may use client.get_events() and pass in the above
+ # parameters, like so:
+ result = client.get_events(queue_id=queue_id, last_event_id=-1)
+ # {code_example|end}
+ validate_against_openapi_schema(result, "/events", "get", "200")
+
+
@openapi_test_function("/server_settings:get")
def get_server_settings(client: Client) -> None:
@@ -1511,6 +1523,7 @@ def test_queues(client: Client) -> None:
# thoroughly tested in zerver/tests/test_event_queue.py, it is not worth
# the effort to come up with asynchronous logic for testing those here.
queue_id = register_queue(client)
+ get_queue(client, queue_id)
deregister_queue(client, queue_id)
register_queue_all_events(client)