tests-backend: Bring stream_recipient.py to 100 percent coverage.

Fixes part of #7089.
This commit is contained in:
Rohan Prashant
2020-04-21 00:30:32 +00:00
committed by Tim Abbott
parent 77195f94c1
commit 44a56a66d0
2 changed files with 14 additions and 1 deletions

View File

@@ -95,7 +95,6 @@ not_yet_fully_covered = {path for target in [
'zerver/lib/queue.py',
'zerver/lib/sqlalchemy_utils.py',
'zerver/lib/storage.py',
'zerver/lib/stream_recipient.py',
'zerver/lib/timeout.py',
'zerver/lib/unminify.py',
'zerver/lib/utils.py',

View File

@@ -26,6 +26,7 @@ from zerver.lib.actions import (
do_set_realm_property,
extract_private_recipients,
extract_stream_indicator,
gather_subscriptions_helper,
get_active_presence_idle_user_ids,
get_client,
get_last_message_id,
@@ -5218,3 +5219,16 @@ class TestBulkGetHuddleUserIds(ZulipTestCase):
def test_bulk_get_huddle_user_ids_empty_list(self) -> None:
self.assertEqual(bulk_get_huddle_user_ids([]), {})
class NoRecipientIDsTest(ZulipTestCase):
def test_no_recipient_ids(self) -> None:
user_profile = self.example_user('cordelia')
Subscription.objects.filter(user_profile=user_profile, recipient__type=Recipient.STREAM).delete()
subs = gather_subscriptions_helper(user_profile)
# Checks that gather_subscriptions_helper will not return anything
# since there will not be any recipients, without crashing.
#
# This covers a rare corner case.
self.assertEqual(len(subs[0]), 0)