mirror of https://github.com/zulip/zulip.git
tests: Use admin client for curl examples test.
This commit is contained in:
parent
bb5463b29a
commit
00455df7f9
|
@ -73,7 +73,7 @@ with test_server_running(force=options.force, external_host='zulipdev.com:9981')
|
|||
)
|
||||
|
||||
test_the_api(client, nonadmin_client)
|
||||
test_generated_curl_examples_for_success(bot_client)
|
||||
test_generated_curl_examples_for_success(client)
|
||||
|
||||
# Test error payloads
|
||||
client = Client(
|
||||
|
|
|
@ -4,7 +4,7 @@ from functools import wraps
|
|||
|
||||
from django.utils.timezone import now as timezone_now
|
||||
|
||||
from zerver.models import get_realm, get_user, Client, UserPresence
|
||||
from zerver.models import Client, UserPresence
|
||||
from zerver.lib.test_classes import ZulipTestCase
|
||||
from zerver.lib.events import do_events_register
|
||||
from zerver.lib.actions import update_user_presence
|
||||
|
@ -47,22 +47,17 @@ def patch_openapi_params(openapi_entry: str, openapi_params: List[Dict[str, Any]
|
|||
param["example"] = realm_param_values[param_name]
|
||||
return openapi_params
|
||||
|
||||
@openapi_param_value_generator(["/messages/{message_id}:get", "/messages/{message_id}/history:get"])
|
||||
@openapi_param_value_generator(["/messages/{message_id}:get", "/messages/{message_id}/history:get",
|
||||
"/messages/{message_id}:patch"])
|
||||
def iago_message_id() -> Dict[str, int]:
|
||||
return {
|
||||
"message_id": helpers.send_stream_message(helpers.example_email("iago"), "Denmark")
|
||||
}
|
||||
|
||||
@openapi_param_value_generator(["/messages/{message_id}:patch"])
|
||||
def default_bot_message_id() -> Dict[str, int]:
|
||||
return {
|
||||
"message_id": helpers.send_stream_message("default-bot@zulip.com", "Denmark")
|
||||
}
|
||||
|
||||
@openapi_param_value_generator(["/messages/flags:post"])
|
||||
def update_flags_message_ids() -> Dict[str, List[int]]:
|
||||
stream_name = "Venice"
|
||||
helpers.subscribe(get_user("default-bot@zulip.com", get_realm("zulip")), stream_name)
|
||||
helpers.subscribe(helpers.example_user("iago"), stream_name)
|
||||
|
||||
messages = []
|
||||
for _ in range(3):
|
||||
|
@ -82,7 +77,7 @@ def get_denmark_stream_id_and_topic() -> Dict[str, Any]:
|
|||
stream_name = "Denmark"
|
||||
topic_name = "Tivoli Gardens"
|
||||
|
||||
helpers.subscribe(get_user("default-bot@zulip.com", get_realm("zulip")), stream_name)
|
||||
helpers.subscribe(helpers.example_user("iago"), stream_name)
|
||||
helpers.send_stream_message(helpers.example_email("hamlet"), stream_name, topic_name=topic_name)
|
||||
|
||||
return {
|
||||
|
@ -92,8 +87,9 @@ def get_denmark_stream_id_and_topic() -> Dict[str, Any]:
|
|||
|
||||
@openapi_param_value_generator(["/users/me/subscriptions/properties:post"])
|
||||
def update_subscription_data() -> Dict[str, List[Dict[str, Any]]]:
|
||||
helpers.subscribe(get_user("default-bot@zulip.com", get_realm("zulip")), "Verona")
|
||||
helpers.subscribe(get_user("default-bot@zulip.com", get_realm("zulip")), "social")
|
||||
profile = helpers.example_user("iago")
|
||||
helpers.subscribe(profile, "Verona")
|
||||
helpers.subscribe(profile, "social")
|
||||
return {
|
||||
"subscription_data": [
|
||||
{"stream_id": helpers.get_stream_id("Verona"), "property": "pin_to_top", "value": True},
|
||||
|
@ -103,10 +99,10 @@ def update_subscription_data() -> Dict[str, List[Dict[str, Any]]]:
|
|||
|
||||
@openapi_param_value_generator(["/events:get"])
|
||||
def get_events() -> Dict[str, Any]:
|
||||
bot_profile = get_user("default-bot@zulip.com", get_realm("zulip"))
|
||||
helpers.subscribe(bot_profile, "Verona")
|
||||
profile = helpers.example_user("iago")
|
||||
helpers.subscribe(profile, "Verona")
|
||||
client = Client.objects.create(name="curl-test-client-1")
|
||||
response = do_events_register(bot_profile, client, event_types=['message', 'realm_emoji'])
|
||||
response = do_events_register(profile, client, event_types=['message', 'realm_emoji'])
|
||||
helpers.send_stream_message(helpers.example_email("hamlet"), "Verona")
|
||||
return {
|
||||
"queue_id": response["queue_id"],
|
||||
|
@ -115,9 +111,9 @@ def get_events() -> Dict[str, Any]:
|
|||
|
||||
@openapi_param_value_generator(["/events:delete"])
|
||||
def delete_event_queue() -> Dict[str, Any]:
|
||||
bot_profile = get_user("default-bot@zulip.com", get_realm("zulip"))
|
||||
profile = helpers.example_user("iago")
|
||||
client = Client.objects.create(name="curl-test-client-2")
|
||||
response = do_events_register(bot_profile, client, event_types=['message'])
|
||||
response = do_events_register(profile, client, event_types=['message'])
|
||||
return {
|
||||
"queue_id": response["queue_id"],
|
||||
"last_event_id": response["last_event_id"],
|
||||
|
|
Loading…
Reference in New Issue