Inital Code

This commit is contained in:
2025-11-24 15:39:05 +00:00
parent b7c419758a
commit 30b7308b6a
13 changed files with 1558 additions and 2 deletions

22
tests/test_chat_server.py Normal file
View File

@@ -0,0 +1,22 @@
import pytest
from chatapp.chat_server import ChatServer
from chatapp.models import UserConnection
import asyncio
@pytest.fixture
def chat_server():
"""Returns a ChatServer instance."""
return ChatServer()
@pytest.mark.asyncio
async def test_add_user(chat_server: ChatServer):
"""Test adding a user to the chat server."""
username = "testuser"
message_queue = asyncio.Queue()
user_conn = UserConnection(username, message_queue)
chat_server.add_user(username, user_conn)
assert username in chat_server.users
assert chat_server.users[username] == user_conn
assert username in chat_server.channels['global'].members