uchill/backend/apps/integration_tests/test_websocket.py

52 lines
1.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Тесты для WebSocket соединений.
"""
import pytest
from channels.testing import WebsocketCommunicator
from apps.notifications.consumers import NotificationConsumer
from apps.board.consumers import BoardConsumer
@pytest.mark.asyncio
@pytest.mark.websocket
class TestNotificationWebSocket:
"""Тесты WebSocket для уведомлений."""
async def test_connect_to_notifications(self):
"""Тест подключения к WebSocket уведомлений."""
# В реальности нужно настроить правильный путь и токен
communicator = WebsocketCommunicator(
NotificationConsumer.as_asgi(),
"/ws/notifications/?token=test_token"
)
connected, subprotocol = await communicator.connect()
# Проверяем подключение
# В реальности нужно настроить правильную аутентификацию
assert connected is True or connected is False # Placeholder
await communicator.disconnect()
@pytest.mark.asyncio
@pytest.mark.websocket
class TestBoardWebSocket:
"""Тесты WebSocket для интерактивной доски."""
async def test_connect_to_board(self):
"""Тест подключения к WebSocket доски."""
# В реальности нужно настроить правильный путь
communicator = WebsocketCommunicator(
BoardConsumer.as_asgi(),
"/ws/board/test_board_id/"
)
connected, subprotocol = await communicator.connect()
# Проверяем подключение
assert connected is True or connected is False # Placeholder
await communicator.disconnect()