test_narrow: Improve group_with_with search test.

The previous test structure was weird, in that it didn't cover the
case where there was at least one group PM thread.
This commit is contained in:
Tim Abbott 2018-02-26 15:10:14 -08:00
parent d032e1ad96
commit 227e5fdcc2
1 changed files with 8 additions and 0 deletions

View File

@ -219,6 +219,7 @@ class NarrowBuilderTest(ZulipTestCase):
self._do_add_term_test(term, 'WHERE id != :param_1') self._do_add_term_test(term, 'WHERE id != :param_1')
def test_add_term_using_group_pm_operator_and_not_the_same_user_as_operand(self) -> None: def test_add_term_using_group_pm_operator_and_not_the_same_user_as_operand(self) -> None:
# Test wtihout any such group PM threads existing
term = dict(operator='group-pm-with', operand=self.example_email("othello")) term = dict(operator='group-pm-with', operand=self.example_email("othello"))
with mock.patch("sqlalchemy.util.warn") as mock_warn: with mock.patch("sqlalchemy.util.warn") as mock_warn:
self._do_add_term_test(term, 'WHERE recipient_id != recipient_id') self._do_add_term_test(term, 'WHERE recipient_id != recipient_id')
@ -226,6 +227,13 @@ class NarrowBuilderTest(ZulipTestCase):
# SQLalchemy warns because this query is a tautology. # SQLalchemy warns because this query is a tautology.
mock_warn.assert_called_once() mock_warn.assert_called_once()
# Test with at least one such group PM thread existing
self.send_huddle_message(self.user_profile.email, [self.example_email("othello"),
self.example_email("cordelia")])
term = dict(operator='group-pm-with', operand=self.example_email("othello"))
self._do_add_term_test(term, 'WHERE recipient_id IN (:recipient_id_1)')
def test_add_term_using_group_pm_operator_not_the_same_user_as_operand_and_negated( def test_add_term_using_group_pm_operator_not_the_same_user_as_operand_and_negated(
self) -> None: # NEGATED self) -> None: # NEGATED
term = dict(operator='group-pm-with', operand=self.example_email("othello"), negated=True) term = dict(operator='group-pm-with', operand=self.example_email("othello"), negated=True)