From 9303c386b856553420eeaa5bcd20dd33fa500ae6 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sat, 8 Feb 2020 23:26:43 +0000 Subject: [PATCH] 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! :) --- zerver/tests/test_custom_profile_data.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zerver/tests/test_custom_profile_data.py b/zerver/tests/test_custom_profile_data.py index ad5a8f9ac1..6643e4fce2 100644 --- a/zerver/tests/test_custom_profile_data.py +++ b/zerver/tests/test_custom_profile_data.py @@ -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, \ try_reorder_realm_custom_profile_fields 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.models import CustomProfileField, \ custom_profile_fields_for_realm, CustomProfileFieldValue, get_realm @@ -644,7 +645,11 @@ class ListCustomProfileFieldTest(CustomProfileFieldTestCase): assert(test_bot) url = "/json/users?client_gravatar=false&include_custom_profile_fields=true" - response = self.client_get(url) + with queries_captured() as queries: + response = self.client_get(url) + + self.assertEqual(len(queries), 4) + self.assertEqual(response.status_code, 200) raw_users_data = response.json()["members"]