From 318f8e86a18edf4a858ebdea1c314995f0188a0c Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Mon, 19 Sep 2016 07:34:01 -0700 Subject: [PATCH] tests: Extract _update_tsvector_index(). --- zerver/tests/test_narrow.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/zerver/tests/test_narrow.py b/zerver/tests/test_narrow.py index 45d9bb47f9..77d73d299a 100644 --- a/zerver/tests/test_narrow.py +++ b/zerver/tests/test_narrow.py @@ -502,6 +502,19 @@ class GetOldMessagesTest(ZulipTestCase): for message in result["messages"]: self.assertEqual(message["sender_email"], "othello@zulip.com") + def _update_tsvector_index(self): + # type: () -> None + # We use brute force here and update our text search index + # for the entire zerver_message table (which is small in test + # mode). In production there is an async process which keeps + # the search index up to date. + with connection.cursor() as cursor: + cursor.execute(""" + UPDATE zerver_message SET + search_tsvector = to_tsvector('zulip.english_us_search', + subject || rendered_content) + """) + @override_settings(USING_PGROONGA=False) def test_get_old_messages_with_search(self): self.login("cordelia@zulip.com") @@ -523,16 +536,7 @@ class GetOldMessagesTest(ZulipTestCase): subject=topic, ) - # We use brute force here and update our text search index - # for the entire zerver_message table (which is small in test - # mode). In production there is an async process which keeps - # the search index up to date. - with connection.cursor() as cursor: - cursor.execute(""" - UPDATE zerver_message SET - search_tsvector = to_tsvector('zulip.english_us_search', - subject || rendered_content) - """) + self._update_tsvector_index() narrow = [ dict(operator='sender', operand='cordelia@zulip.com'),