Skip to content

Commit

Permalink
ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gold-tooth committed Apr 4, 2024
1 parent 8c3f659 commit 3a1b57c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
11 changes: 4 additions & 7 deletions src/chat/routers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from typing import Annotated
import uuid
from typing import Annotated
from uuid import UUID


from motor.motor_asyncio import AsyncIOMotorClient

from src.database import mongo
from bson.binary import Binary

from fastapi import APIRouter, Depends
from fastapi.websockets import WebSocket
from orjson import JSONEncodeError, orjson
Expand All @@ -24,6 +20,7 @@
update_message,
ws_manager,
)
from src.database import mongo

ws_router = APIRouter(
prefix="/chat",
Expand Down Expand Up @@ -74,7 +71,7 @@ async def websocket_chat(


@ws_router.get("/messages/{match_id}")
async def get_latest_messages(match_id):
async def get_latest_messages(match_id: UUID):

collection = mongo.collection

Expand Down
1 change: 0 additions & 1 deletion src/chat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,4 @@ async def update_message(ws_msg: WSMessageRequest, ws: WebSocket, user: AuthUser

await send_ws_message(ws, msg, WSAction.UPDATE)


ws_manager = WebSocketConnectionManager()
15 changes: 8 additions & 7 deletions tests/test_acceptance.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import uuid

import orjson
from async_asgi_testclient import TestClient
from bson.binary import Binary
from dirty_equals import IsStr, IsUUID
from fastapi import status
from src.mongodb.mongodb import Mongo
import uuid
from bson.binary import Binary

from src.chat.schemas import MessageStatus, WSAction, WSStatus
from src.chat.utils import orjson_dumps
from src.mongodb.mongodb import Mongo


class TestAcceptance:
Expand Down Expand Up @@ -470,9 +471,9 @@ async def test_get_latest_messages(self, mongo: Mongo, async_client: TestClient)
"from_id": Binary(from_id.bytes, subtype=3),
"to_id": Binary(to_id.bytes, subtype=3),
"text": text,
"created_at": '2023-01-01T00:00:00',
"updated_at": '2023-01-01T00:00:00',
"status": "sent"
"created_at": "2023-01-01T00:00:00",
"updated_at": "2023-01-01T00:00:00",
"status": "sent",
}

collection.insert_one(message)
Expand All @@ -493,4 +494,4 @@ async def test_get_latest_messages(self, mongo: Mongo, async_client: TestClient)
assert result[0]["updated_at"] == message["updated_at"]
assert result[0]["status"] == message["status"]

collection.delete_one({'match_id': match_id})
collection.delete_one({"match_id": match_id})

0 comments on commit 3a1b57c

Please sign in to comment.