Add test_non_string_narrow_operand_in_dict().

This commit is contained in:
Steve Howell 2016-07-26 14:53:14 -07:00 committed by Tim Abbott
parent b2d1c18268
commit 81cd9d33e4
1 changed files with 11 additions and 0 deletions

View File

@ -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: