Skip to content

Commit

Permalink
tests: Verify database queries for realm administrators.
Browse files Browse the repository at this point in the history
This number is way too high, because of a recent regression.  Adding a
test here lets us prevent similar regressions in the future and
provides an easy way to be sure if we've fixed the issue.
  • Loading branch information
timabbott committed Mar 27, 2018
1 parent 07971d3 commit 5404eda
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions zerver/tests/test_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,17 @@ def test_home(self) -> None:
realm_bots_actual_keys = sorted([str(key) for key in page_params['realm_bots'][0].keys()])
self.assertEqual(realm_bots_actual_keys, realm_bots_expected_keys)

def test_num_queries_for_realm_admin(self) -> None:
# Verify number of queries for Realm admin isn't much higher than for normal users.
self.login(self.example_email("iago"))
flush_per_request_caches()
with queries_captured() as queries:
with patch('zerver.lib.cache.cache_set') as cache_mock:
result = self._get_home_page()
self.assertEqual(result.status_code, 200)
self.assert_length(cache_mock.call_args_list, 17)
self.assert_length(queries, 60)

@slow("Creates and subscribes 10 users in a loop. Should use bulk queries.")
def test_num_queries_with_streams(self) -> None:
main_user = self.example_user('hamlet')
Expand Down

0 comments on commit 5404eda

Please sign in to comment.