Inital Code
This commit is contained in:
22
tests/test_chat_server.py
Normal file
22
tests/test_chat_server.py
Normal 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
|
||||
Reference in New Issue
Block a user