mirror of https://github.com/zulip/zulip.git
actions: Move part into zerver.lib.test_classes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
e01faebd7e
commit
729019acdd
|
@ -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)]
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue