diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index f10d294b4c..70ee4a1479 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -1409,13 +1409,6 @@ def pick_color_helper(user_profile, subs): else: return STREAM_ASSIGNMENT_COLORS[len(used_colors) % len(STREAM_ASSIGNMENT_COLORS)] -def get_subscription(stream_name, user_profile): - # type: (Text, UserProfile) -> Subscription - stream = get_stream(stream_name, user_profile.realm) - recipient = get_recipient(Recipient.STREAM, stream.id) - return Subscription.objects.get(user_profile=user_profile, - recipient=recipient, active=True) - def validate_user_access_to_subscribers(user_profile, stream): # type: (Optional[UserProfile], Stream) -> None """ Validates whether the user can view the subscribers of a stream. Raises a JsonableError if: diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py index 8f452ac43f..88f4bfa4bc 100644 --- a/zerver/lib/test_helpers.py +++ b/zerver/lib/test_helpers.py @@ -30,6 +30,7 @@ from zerver.lib.actions import ( ) from zerver.models import ( + get_recipient, get_stream, get_user_profile_by_email, Client, @@ -206,6 +207,13 @@ def most_recent_message(user_profile): usermessage = most_recent_usermessage(user_profile) return usermessage.message +def get_subscription(stream_name, user_profile): + # type: (Text, UserProfile) -> Subscription + stream = get_stream(stream_name, user_profile.realm) + recipient = get_recipient(Recipient.STREAM, stream.id) + return Subscription.objects.get(user_profile=user_profile, + recipient=recipient, active=True) + def get_user_messages(user_profile): # type: (UserProfile) -> List[Message] query = UserMessage.objects. \ diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 76d02a840e..d5b3c27787 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -60,11 +60,10 @@ from zerver.lib.actions import ( do_add_realm_alias, do_remove_realm_alias, fetch_initial_state_data, - get_subscription ) from zerver.lib.message import render_markdown -from zerver.lib.test_helpers import POSTRequestMock +from zerver.lib.test_helpers import POSTRequestMock, get_subscription from zerver.lib.test_classes import ( ZulipTestCase, ) diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py index 19f23e960c..2d4542fa43 100644 --- a/zerver/tests/test_subs.py +++ b/zerver/tests/test_subs.py @@ -9,7 +9,7 @@ from django.utils.translation import ugettext as _ from zerver.lib import cache from zerver.lib.test_helpers import ( - queries_captured, tornado_redirected_to_list + get_subscription, queries_captured, tornado_redirected_to_list ) from zerver.lib.test_classes import ( @@ -39,7 +39,7 @@ from zerver.lib.actions import ( do_create_realm, do_remove_default_stream, do_set_realm_create_stream_by_admins_only, gather_subscriptions_helper, bulk_add_subscriptions, bulk_remove_subscriptions, gather_subscriptions, get_default_streams_for_realm, get_realm, get_stream, - get_user_profile_by_email, set_default_streams, get_subscription, + get_user_profile_by_email, set_default_streams, create_stream_if_needed, create_streams_if_needed, active_user_ids )