diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 369dd38c7b..8b13789179 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -1,12 +1 @@ -from typing import List -from zerver.lib.topic import filter_by_topic_name_via_message -from zerver.models import Message, Stream, UserMessage, UserProfile - - -def get_topic_messages(user_profile: UserProfile, stream: Stream, topic_name: str) -> List[Message]: - query = UserMessage.objects.filter( - user_profile=user_profile, - message__recipient=stream.recipient, - ).order_by("id") - return [um.message for um in filter_by_topic_name_via_message(query, topic_name)] diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index c67cf854dc..3ed055afd2 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -69,6 +69,7 @@ from zerver.lib.test_console_output import ( tee_stdout_and_find_extra_console_output, ) from zerver.lib.test_helpers import find_key_by_email, instrument_url +from zerver.lib.topic import filter_by_topic_name_via_message from zerver.lib.user_groups import get_system_user_group_for_user from zerver.lib.users import get_api_key from zerver.lib.validator import check_string @@ -1816,3 +1817,11 @@ class MigrationsTestCase(ZulipTestCase): # nocoverage def setUpBeforeMigration(self, apps: StateApps) -> None: pass # nocoverage + + +def get_topic_messages(user_profile: UserProfile, stream: Stream, topic_name: str) -> List[Message]: + query = UserMessage.objects.filter( + user_profile=user_profile, + message__recipient=stream.recipient, + ).order_by("id") + return [um.message for um in filter_by_topic_name_via_message(query, topic_name)] diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py index 7d2f27eb2a..fdf3102510 100644 --- a/zerver/tests/test_message_edit.py +++ b/zerver/tests/test_message_edit.py @@ -18,9 +18,8 @@ from zerver.actions.reactions import do_add_reaction from zerver.actions.realm_settings import do_change_realm_plan_type, do_set_realm_property from zerver.actions.streams import do_change_stream_post_policy, do_deactivate_stream from zerver.actions.users import do_change_user_role -from zerver.lib.actions import get_topic_messages from zerver.lib.message import MessageDict, has_message_access, messages_for_ids -from zerver.lib.test_classes import ZulipTestCase +from zerver.lib.test_classes import ZulipTestCase, get_topic_messages from zerver.lib.test_helpers import cache_tries_captured, queries_captured from zerver.lib.topic import RESOLVED_TOPIC_PREFIX, TOPIC_NAME from zerver.lib.user_topics import ( diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py index 8a731de8bf..07f987f359 100644 --- a/zerver/tests/test_subs.py +++ b/zerver/tests/test_subs.py @@ -33,7 +33,6 @@ from zerver.actions.streams import ( do_deactivate_stream, ) from zerver.actions.users import do_change_user_role, do_deactivate_user -from zerver.lib.actions import get_topic_messages from zerver.lib.exceptions import JsonableError from zerver.lib.message import UnreadStreamInfo, aggregate_unread_data, get_raw_unread_data from zerver.lib.response import json_success @@ -66,7 +65,7 @@ from zerver.lib.subscription_info import ( gather_subscriptions_helper, validate_user_access_to_subscribers_helper, ) -from zerver.lib.test_classes import ZulipTestCase +from zerver.lib.test_classes import ZulipTestCase, get_topic_messages from zerver.lib.test_helpers import ( HostRequestMock, cache_tries_captured,