Test "empty list" logic in exclude_muting_conditions().

This commit is contained in:
Steve Howell 2016-07-23 08:07:38 -07:00 committed by Tim Abbott
parent 196e021a7f
commit ee2007136d
1 changed files with 15 additions and 0 deletions

View File

@ -748,9 +748,24 @@ class GetOldMessagesTest(AuthedTestCase):
realm = get_realm('zulip.com')
create_stream_if_needed(realm, 'devel')
user_profile = get_user_profile_by_email("hamlet@zulip.com")
# Test the do-nothing case first.
user_profile.muted_topics = ujson.dumps([['irrelevant_stream', 'irrelevant_topic']])
user_profile.save()
# If nothing relevant is muted, then exclude_muting_conditions()
# should return an empty list.
narrow = [
dict(operator='stream', operand='Scotland'),
]
muting_conditions = exclude_muting_conditions(user_profile, narrow)
self.assertEqual(muting_conditions, [])
# Ok, now set up our muted topics to include a topic relevant to our narrow.
user_profile.muted_topics = ujson.dumps([['Scotland', 'golf'], ['devel', 'css'], ['bogus', 'bogus']])
user_profile.save()
# And verify that our query will exclude them.
narrow = [
dict(operator='stream', operand='Scotland'),
]