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.

test_event_system: Fix test_queries test.

Sahil Batraff8f797c5c0c
diff --git a/zerver/tests/test_event_system.py b/zerver/tests/test_event_system.py
index 41112f2bb6a..2098fe68b04 100644
--- a/zerver/tests/test_event_system.py
+++ b/zerver/tests/test_event_system.py
@@ -1185,7 +1185,7 @@ class FetchQueriesTest(ZulipTestCase):
muted_users=1,
onboarding_steps=1,
presence=1,
- realm=1,
+ realm=3,
realm_bot=1,
realm_domains=1,
realm_embedded_bots=0,
@@ -1217,6 +1217,11 @@ class FetchQueriesTest(ZulipTestCase):
self.assertEqual(wanted_event_types, set(expected_counts))
+ # Fetch realm again here so that the cached foreign key fields
+ # while testing the above case does not reduce the query count
+ # and we test the actual query count for each event type.
+ realm = get_realm_with_settings(realm_id=user.realm_id)
+
for event_type in sorted(wanted_event_types):
count = expected_counts[event_type]
with self.assert_database_query_count(count):