openapi-tests: Add coverage for validating example events.

Adds testing coverage for validating the documented examples for
each event in the `api/get-events` endpoint documentation.

This will help us catch basic typos / mistakes when adding new
event examples. And if fields / objects are removed or modified
for existing events in the API, then failing to update the
examples for those changes will also be caught by this additional
test coverage.

Adding new fields / objects to existing event schemas without
updating the example will not be caught unless the new field
is marked as required in the documentation.
This commit is contained in:
Lauryn Menard
2023-06-21 19:59:26 +02:00
committed by Tim Abbott
parent b1b0296a21
commit 6f58994ef4
2 changed files with 21 additions and 3 deletions

View File

@@ -1599,11 +1599,15 @@ def test_streams(client: Client, nonadmin_client: Client) -> None:
def test_queues(client: Client) -> None:
# Note that the example for api/get-events is not tested.
# Note that the example for api/get-events is not tested here.
#
# Since, methods such as client.get_events() or client.call_on_each_message
# are blocking calls and since the event queue backend is already
# 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.
#
# We do validate endpoint example responses in zerver/tests/test_openapi.py,
# as well as the example events returned by api/get-events.
queue_id = register_queue(client)
get_queue(client, queue_id)
deregister_queue(client, queue_id)