mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
test_helpers: Move get_subscription out of actions.py.
It's no longer used by anything other than test code.
This commit is contained in:
@@ -1409,13 +1409,6 @@ def pick_color_helper(user_profile, subs):
|
|||||||
else:
|
else:
|
||||||
return STREAM_ASSIGNMENT_COLORS[len(used_colors) % len(STREAM_ASSIGNMENT_COLORS)]
|
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):
|
def validate_user_access_to_subscribers(user_profile, stream):
|
||||||
# type: (Optional[UserProfile], Stream) -> None
|
# type: (Optional[UserProfile], Stream) -> None
|
||||||
""" Validates whether the user can view the subscribers of a stream. Raises a JsonableError if:
|
""" Validates whether the user can view the subscribers of a stream. Raises a JsonableError if:
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ from zerver.lib.actions import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from zerver.models import (
|
from zerver.models import (
|
||||||
|
get_recipient,
|
||||||
get_stream,
|
get_stream,
|
||||||
get_user_profile_by_email,
|
get_user_profile_by_email,
|
||||||
Client,
|
Client,
|
||||||
@@ -206,6 +207,13 @@ def most_recent_message(user_profile):
|
|||||||
usermessage = most_recent_usermessage(user_profile)
|
usermessage = most_recent_usermessage(user_profile)
|
||||||
return usermessage.message
|
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):
|
def get_user_messages(user_profile):
|
||||||
# type: (UserProfile) -> List[Message]
|
# type: (UserProfile) -> List[Message]
|
||||||
query = UserMessage.objects. \
|
query = UserMessage.objects. \
|
||||||
|
|||||||
@@ -60,11 +60,10 @@ from zerver.lib.actions import (
|
|||||||
do_add_realm_alias,
|
do_add_realm_alias,
|
||||||
do_remove_realm_alias,
|
do_remove_realm_alias,
|
||||||
fetch_initial_state_data,
|
fetch_initial_state_data,
|
||||||
get_subscription
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from zerver.lib.message import render_markdown
|
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 (
|
from zerver.lib.test_classes import (
|
||||||
ZulipTestCase,
|
ZulipTestCase,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from django.utils.translation import ugettext as _
|
|||||||
from zerver.lib import cache
|
from zerver.lib import cache
|
||||||
|
|
||||||
from zerver.lib.test_helpers import (
|
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 (
|
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,
|
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_helper, bulk_add_subscriptions, bulk_remove_subscriptions,
|
||||||
gather_subscriptions, get_default_streams_for_realm, get_realm, get_stream,
|
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
|
create_stream_if_needed, create_streams_if_needed, active_user_ids
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user