search: Add tests for multiple unicode search operands.

This commit is contained in:
Sampriti Panda 2017-10-31 22:54:00 +05:30 committed by Tim Abbott
parent 04a79800b9
commit d6df408a0e
1 changed files with 31 additions and 1 deletions

View File

@ -880,7 +880,7 @@ class GetOldMessagesTest(ZulipTestCase):
('meetings', 'please bring your laptops to take notes'), ('meetings', 'please bring your laptops to take notes'),
('dinner', 'Anybody staying late tonight?'), ('dinner', 'Anybody staying late tonight?'),
('urltest', 'https://google.com'), ('urltest', 'https://google.com'),
(u'日本', u'こんにちは。今日はいい天気ですね。'), (u'日本', u'こんに ちは 今日は いい 天気ですね。'),
(u'日本', u'今朝はごはんを食べました。'), (u'日本', u'今朝はごはんを食べました。'),
(u'日本', u'昨日、日本 のお菓子を送りました。'), (u'日本', u'昨日、日本 のお菓子を送りました。'),
('english', u'I want to go to 日本!'), ('english', u'I want to go to 日本!'),
@ -983,6 +983,21 @@ class GetOldMessagesTest(ZulipTestCase):
english_message['match_content'], english_message['match_content'],
u'<p>I want to go to <span class="highlight">日本</span>!</p>') u'<p>I want to go to <span class="highlight">日本</span>!</p>')
# Multiple search operands with unicode
multi_search_narrow = [
dict(operator='search', operand='ちは'),
dict(operator='search', operand='今日は'),
]
multi_search_result = self.get_and_check_messages(dict(
narrow=ujson.dumps(multi_search_narrow),
anchor=next_message_id,
num_after=10,
num_before=0,
))
self.assertEqual(len(multi_search_result['messages']), 1)
self.assertEqual(multi_search_result['messages'][0]['match_content'],
'<p>こんに <span class="highlight">ちは</span> 。 <span class="highlight">今日は</span> いい 天気ですね。</p>')
@override_settings(USING_PGROONGA=False) @override_settings(USING_PGROONGA=False)
def test_get_messages_with_search_not_subscribed(self): def test_get_messages_with_search_not_subscribed(self):
# type: () -> None # type: () -> None
@ -1095,6 +1110,21 @@ class GetOldMessagesTest(ZulipTestCase):
self.assertEqual(multi_search_result['messages'][0]['match_content'], self.assertEqual(multi_search_result['messages'][0]['match_content'],
'<p><span class="highlight">Can</span> you <span class="highlight">speak</span> <a href="https://en.wikipedia.org/wiki/Japanese" target="_blank" title="https://en.wikipedia.org/wiki/Japanese">https://en.<span class="highlight">wiki</span>pedia.org/<span class="highlight">wiki</span>/Japanese</a>?</p>') '<p><span class="highlight">Can</span> you <span class="highlight">speak</span> <a href="https://en.wikipedia.org/wiki/Japanese" target="_blank" title="https://en.wikipedia.org/wiki/Japanese">https://en.<span class="highlight">wiki</span>pedia.org/<span class="highlight">wiki</span>/Japanese</a>?</p>')
# Multiple search operands with unicode
multi_search_narrow = [
dict(operator='search', operand='朝は'),
dict(operator='search', operand='べました'),
]
multi_search_result = self.get_and_check_messages(dict(
narrow=ujson.dumps(multi_search_narrow),
anchor=next_message_id,
num_after=10,
num_before=0,
))
self.assertEqual(len(multi_search_result['messages']), 1)
self.assertEqual(multi_search_result['messages'][0]['match_content'],
'<p>今<span class="highlight">朝は</span>ごはんを食<span class="highlight">べました</span>。</p>')
narrow = [dict(operator='search', operand='https://google.com')] narrow = [dict(operator='search', operand='https://google.com')]
link_search_result = self.get_and_check_messages(dict( link_search_result = self.get_and_check_messages(dict(
narrow=ujson.dumps(narrow), narrow=ujson.dumps(narrow),