From 81cd9d33e4eff3107704c0e24550fe76615e119a Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 26 Jul 2016 14:53:14 -0700 Subject: [PATCH] Add test_non_string_narrow_operand_in_dict(). --- zerver/tests/test_narrow.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zerver/tests/test_narrow.py b/zerver/tests/test_narrow.py index 9ff74e7f49..9aeb014206 100644 --- a/zerver/tests/test_narrow.py +++ b/zerver/tests/test_narrow.py @@ -644,6 +644,17 @@ class GetOldMessagesTest(AuthedTestCase): self.assert_json_error_contains(result, "Invalid narrow operator: unknown operator") + def test_non_string_narrow_operand_in_dict(self): + """ + We expect search operands to be strings, not integers. + """ + self.login("hamlet@zulip.com") + not_a_string = 42 + narrow = [dict(operator='stream', operand=not_a_string)] + params = dict(anchor=0, num_before=0, num_after=0, narrow=ujson.dumps(narrow)) + result = self.client.get("/json/messages", params) + self.assert_json_error_contains(result, 'elem["operand"] is not a string') + def exercise_bad_narrow_operand(self, operator, operands, error_msg): other_params = [("anchor", 0), ("num_before", 0), ("num_after", 0)] for operand in operands: