|
12 | 12 | from tests.factories.rule.group import TelegramChatRuleGroupFactory |
13 | 13 | from tests.utils.misc import AsyncIterator |
14 | 14 | from core.actions.chat import TelegramChatAction |
15 | | -from core.constants import REQUIRED_BOT_PRIVILEGES |
| 15 | +from core.constants import ( |
| 16 | + REQUIRED_BOT_PRIVILEGES, |
| 17 | + DEFAULT_MANAGED_USERS_PUBLIC_THRESHOLD, |
| 18 | +) |
16 | 19 | from core.dtos.chat import ( |
17 | 20 | TelegramChatDTO, |
18 | 21 | TelegramChatOrderingRuleDTO, |
@@ -66,6 +69,9 @@ def test_get_all__success(db_session: Session) -> None: |
66 | 69 | # For get_all it's mandatory that chat has at least one rule group to be treated as active |
67 | 70 | for chat in chats: |
68 | 71 | TelegramChatRuleGroupFactory.with_session(db_session).create(chat=chat) |
| 72 | + TelegramChatUserFactory.with_session(db_session).create_batch( |
| 73 | + DEFAULT_MANAGED_USERS_PUBLIC_THRESHOLD, chat=chat |
| 74 | + ) |
69 | 75 | # The default ordering is by users-count -> ID |
70 | 76 | ordered_chats = ( |
71 | 77 | db_session.query(TelegramChat) |
@@ -125,8 +131,11 @@ def test_get_all__pagination__success( |
125 | 131 | # For get_all it's mandatory that chat has at least one rule group to be treated as active |
126 | 132 | for chat in chats: |
127 | 133 | TelegramChatRuleGroupFactory.with_session(db_session).create(chat=chat) |
| 134 | + TelegramChatUserFactory.with_session(db_session).create_batch( |
| 135 | + DEFAULT_MANAGED_USERS_PUBLIC_THRESHOLD, chat=chat |
| 136 | + ) |
128 | 137 |
|
129 | | - ordered_chats = sorted(chats, key=lambda chat: chat.id) |
| 138 | + ordered_chats = sorted(chats, key=lambda _chat: _chat.id) |
130 | 139 |
|
131 | 140 | # Act |
132 | 141 | action = TelegramChatAction(db_session) |
@@ -172,6 +181,9 @@ def test_get_all__sorting__success(db_session: Session, is_ascending: bool) -> N |
172 | 181 | # For get_all it's mandatory that chat has at least one rule group to be treated as active |
173 | 182 | for _chat in chats: |
174 | 183 | TelegramChatRuleGroupFactory.with_session(db_session).create(chat=_chat) |
| 184 | + TelegramChatUserFactory.with_session(db_session).create_batch( |
| 185 | + DEFAULT_MANAGED_USERS_PUBLIC_THRESHOLD, chat=_chat |
| 186 | + ) |
175 | 187 |
|
176 | 188 | # Assign user to one chat only to ensure it doesn't impact results |
177 | 189 | TelegramChatUserFactory.with_session(db_session).create( |
|
0 commit comments