fix: Lint fixes of last tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Tests for socket API endpoints."""
|
||||
# ruff: noqa: ARG002, PLR2004, ANN001, ANN201
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
@@ -27,7 +28,7 @@ class TestSocketEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_socket_manager,
|
||||
):
|
||||
) -> None:
|
||||
"""Test getting socket status for authenticated user."""
|
||||
response = await authenticated_client.get("/api/v1/socket/status")
|
||||
|
||||
@@ -42,7 +43,7 @@ class TestSocketEndpoints:
|
||||
assert isinstance(data["connected"], bool)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_socket_status_unauthenticated(self, client: AsyncClient):
|
||||
async def test_get_socket_status_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test getting socket status without authentication."""
|
||||
response = await client.get("/api/v1/socket/status")
|
||||
assert response.status_code == 401
|
||||
@@ -53,7 +54,7 @@ class TestSocketEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_socket_manager,
|
||||
):
|
||||
) -> None:
|
||||
"""Test sending message to specific user successfully."""
|
||||
target_user_id = 2
|
||||
message = "Hello there!"
|
||||
@@ -87,7 +88,7 @@ class TestSocketEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_socket_manager,
|
||||
):
|
||||
) -> None:
|
||||
"""Test sending message to user who is not connected."""
|
||||
target_user_id = 999
|
||||
message = "Hello there!"
|
||||
@@ -108,7 +109,7 @@ class TestSocketEndpoints:
|
||||
assert data["message"] == "User not connected"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_message_unauthenticated(self, client: AsyncClient):
|
||||
async def test_send_message_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test sending message without authentication."""
|
||||
response = await client.post(
|
||||
"/api/v1/socket/send-message",
|
||||
@@ -122,7 +123,7 @@ class TestSocketEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_socket_manager,
|
||||
):
|
||||
) -> None:
|
||||
"""Test broadcasting message to all users successfully."""
|
||||
message = "Important announcement!"
|
||||
|
||||
@@ -148,7 +149,7 @@ class TestSocketEndpoints:
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_broadcast_message_unauthenticated(self, client: AsyncClient):
|
||||
async def test_broadcast_message_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test broadcasting message without authentication."""
|
||||
response = await client.post(
|
||||
"/api/v1/socket/broadcast",
|
||||
@@ -159,7 +160,7 @@ class TestSocketEndpoints:
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_message_missing_parameters(
|
||||
self, authenticated_client: AsyncClient, authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test sending message with missing parameters."""
|
||||
# Missing target_user_id
|
||||
response = await authenticated_client.post(
|
||||
@@ -178,7 +179,7 @@ class TestSocketEndpoints:
|
||||
@pytest.mark.asyncio
|
||||
async def test_broadcast_message_missing_parameters(
|
||||
self, authenticated_client: AsyncClient, authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test broadcasting message with missing parameters."""
|
||||
response = await authenticated_client.post("/api/v1/socket/broadcast")
|
||||
assert response.status_code == 422
|
||||
@@ -186,7 +187,7 @@ class TestSocketEndpoints:
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_message_invalid_user_id(
|
||||
self, authenticated_client: AsyncClient, authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test sending message with invalid user ID."""
|
||||
response = await authenticated_client.post(
|
||||
"/api/v1/socket/send-message",
|
||||
@@ -200,7 +201,7 @@ class TestSocketEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_socket_manager,
|
||||
):
|
||||
) -> None:
|
||||
"""Test that socket status correctly shows if user is connected."""
|
||||
# Test when user is connected
|
||||
mock_socket_manager.get_connected_users.return_value = [
|
||||
|
||||
Reference in New Issue
Block a user