|
7 | 7 | from respx.router import MockRouter |
8 | 8 |
|
9 | 9 | from pybotx import ChatCreationError, ChatCreationProhibitedError, ChatTypes |
10 | | -from pybotx.missing import Undefined |
11 | 10 | from tests.testkit import BotXRequest, error_payload, mock_botx, ok_payload |
12 | 11 |
|
13 | 12 | pytestmark = [ |
@@ -216,41 +215,20 @@ def test__create_chat_payload__convert_chat_type_validator() -> None: |
216 | 215 | from pybotx.client.chats_api.create_chat import BotXAPICreateChatRequestPayload |
217 | 216 | from pybotx.models.enums import ChatTypes, APIChatTypes |
218 | 217 |
|
219 | | - # Arrange |
220 | | - name = "Test Chat" |
221 | | - description = "Test Description" |
222 | | - chat_type = ChatTypes.PERSONAL_CHAT |
223 | | - members = [UUID("2fc83441-366a-49ba-81fc-6c39f065bb58")] |
224 | | - shared_history = Undefined |
225 | | - avatar = None |
226 | | - |
227 | | - # Act |
228 | | - payload = BotXAPICreateChatRequestPayload.from_domain( |
229 | | - name=name, |
230 | | - chat_type=chat_type, |
231 | | - members=members, |
232 | | - shared_history=shared_history, |
233 | | - description=description, |
234 | | - avatar=avatar, |
235 | | - ) |
| 218 | + # Test with ChatTypes enum |
| 219 | + values = {"chat_type": ChatTypes.GROUP_CHAT} |
| 220 | + result = BotXAPICreateChatRequestPayload._convert_chat_type(values) # type: ignore[operator] |
| 221 | + assert result["chat_type"] == APIChatTypes.GROUP_CHAT |
236 | 222 |
|
237 | | - # Assert |
238 | | - assert payload.name == name |
239 | | - assert payload.description == description |
240 | | - assert payload.chat_type == APIChatTypes.CHAT |
241 | | - assert payload.members == members |
242 | | - |
243 | | - # Test with APIChatTypes |
244 | | - api_chat_type = APIChatTypes.CHANNEL |
245 | | - payload = BotXAPICreateChatRequestPayload.from_domain( |
246 | | - name=name, |
247 | | - chat_type=api_chat_type, |
248 | | - members=members, |
249 | | - shared_history=shared_history, |
250 | | - description=description, |
251 | | - avatar=avatar, |
252 | | - ) |
253 | | - assert payload.chat_type == api_chat_type |
| 223 | + # Test with APIChatTypes value (should remain unchanged) |
| 224 | + values = {"chat_type": APIChatTypes.CHAT} # type: ignore[dict-item] |
| 225 | + result = BotXAPICreateChatRequestPayload._convert_chat_type(values) # type: ignore[operator] |
| 226 | + assert result["chat_type"] == APIChatTypes.CHAT |
| 227 | + |
| 228 | + # Test with missing chat_type key |
| 229 | + values = {"name": "test"} # type: ignore[dict-item] |
| 230 | + result = BotXAPICreateChatRequestPayload._convert_chat_type(values) # type: ignore[operator] |
| 231 | + assert result == {"name": "test"} |
254 | 232 |
|
255 | 233 |
|
256 | 234 | def test__create_chat_payload__serialize_chat_type_from_domain() -> None: |
|
0 commit comments