mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
tests: Count queries for /json/users.
I am trying to optimize a query in this endpoint. I don't think I'll actually reduce the number of queries, but I wanted to capture the query and this was the easiest way to do it, so might as well check in the code! :)
This commit is contained in:
@@ -6,6 +6,7 @@ from zerver.lib.actions import try_add_realm_custom_profile_field, \
|
|||||||
do_update_user_custom_profile_data_if_changed, do_remove_realm_custom_profile_field, \
|
do_update_user_custom_profile_data_if_changed, do_remove_realm_custom_profile_field, \
|
||||||
try_reorder_realm_custom_profile_fields
|
try_reorder_realm_custom_profile_fields
|
||||||
from zerver.lib.test_classes import ZulipTestCase
|
from zerver.lib.test_classes import ZulipTestCase
|
||||||
|
from zerver.lib.test_helpers import queries_captured
|
||||||
from zerver.lib.bugdown import convert as bugdown_convert
|
from zerver.lib.bugdown import convert as bugdown_convert
|
||||||
from zerver.models import CustomProfileField, \
|
from zerver.models import CustomProfileField, \
|
||||||
custom_profile_fields_for_realm, CustomProfileFieldValue, get_realm
|
custom_profile_fields_for_realm, CustomProfileFieldValue, get_realm
|
||||||
@@ -644,7 +645,11 @@ class ListCustomProfileFieldTest(CustomProfileFieldTestCase):
|
|||||||
assert(test_bot)
|
assert(test_bot)
|
||||||
|
|
||||||
url = "/json/users?client_gravatar=false&include_custom_profile_fields=true"
|
url = "/json/users?client_gravatar=false&include_custom_profile_fields=true"
|
||||||
|
with queries_captured() as queries:
|
||||||
response = self.client_get(url)
|
response = self.client_get(url)
|
||||||
|
|
||||||
|
self.assertEqual(len(queries), 4)
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
raw_users_data = response.json()["members"]
|
raw_users_data = response.json()["members"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user