From 815bdd6704a682ea911cf5d9f3ce15e61996a863 Mon Sep 17 00:00:00 2001 From: urec56 Date: Tue, 18 Jun 2024 16:41:31 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=81=D0=BB=D0=B8=D0=BF=20=D0=B4=D0=BB=D1=8F=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alembic.ini | 2 +- app/chat/websocket.py | 2 -- app/dao/base.py | 6 ++++++ app/dao/chat.py | 5 ----- app/dao/user.py | 5 ----- app/main.py | 1 - app/users/router.py | 4 ++-- app/utils/auth.py | 1 - tests/integration_tests/users_api_test.py | 3 --- 9 files changed, 9 insertions(+), 20 deletions(-) diff --git a/alembic.ini b/alembic.ini index 7fcbe09..58fcfe7 100644 --- a/alembic.ini +++ b/alembic.ini @@ -8,7 +8,7 @@ script_location = app/migrations # Uncomment the line below if you want the files to be prepended with date and time # see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file # for all available tokens -file_template = %%(year)d-%%(month).2d-%%(day).2d_%%(slug)s +file_template = %%(year)d-%%(month).2d-%%(day).2d_%%(hour).2d-%%(minute).2d-%%(second).2d_%%(slug)s # sys.path path, will be prepended to sys.path if present. # defaults to the current working directory. diff --git a/app/chat/websocket.py b/app/chat/websocket.py index 8e41b76..b576b17 100644 --- a/app/chat/websocket.py +++ b/app/chat/websocket.py @@ -1,5 +1,3 @@ -import logging - import websockets from fastapi import WebSocket, WebSocketDisconnect, Depends diff --git a/app/dao/base.py b/app/dao/base.py index 0e1b8dc..9fbe965 100644 --- a/app/dao/base.py +++ b/app/dao/base.py @@ -1,5 +1,7 @@ from sqlalchemy.ext.asyncio import AsyncSession +from app.database import engine + class BaseDAO: model = None @@ -7,3 +9,7 @@ class BaseDAO: def __init__(self, session: AsyncSession): self.session = session + @staticmethod + def check_query_compile(query): + print(query.compile(engine, compile_kwargs={"literal_binds": True})) # Проверка SQL запроса + diff --git a/app/dao/chat.py b/app/dao/chat.py index 69be7dc..2d29ee4 100644 --- a/app/dao/chat.py +++ b/app/dao/chat.py @@ -4,7 +4,6 @@ from sqlalchemy.exc import IntegrityError, NoResultFound from sqlalchemy.orm import aliased from app.dao.base import BaseDAO -from app.database import engine from app.chat.exceptions import ( UserAlreadyInChatException, UserAlreadyPinnedChatException, @@ -25,10 +24,6 @@ from app.models.user_chat import UserChat class ChatDAO(BaseDAO): model = Chat - @staticmethod - def check_query_compile(query): - print(query.compile(engine, compile_kwargs={"literal_binds": True})) # Проверка SQL запроса - async def find_one(self, chat_id: int, user_id: int) -> SChat: try: query = ( diff --git a/app/dao/user.py b/app/dao/user.py index 393f702..a5c5328 100644 --- a/app/dao/user.py +++ b/app/dao/user.py @@ -4,7 +4,6 @@ from sqlalchemy.exc import MultipleResultsFound, IntegrityError, NoResultFound from app.chat.shemas import SAllowedChats from app.dao.base import BaseDAO -from app.database import engine # noqa from app.exceptions import IncorrectDataException, UserNotFoundException from app.users.exceptions import UserAlreadyExistsException from app.models.chat import Chat @@ -17,10 +16,6 @@ from app.users.schemas import SUser, SUserAvatars, SUsers class UserDAO(BaseDAO): model = Users - @staticmethod - def check_query_compile(query): - print(query.compile(engine, compile_kwargs={"literal_binds": True})) # Проверка SQL запроса - async def add(self, **data) -> SUser: try: stmt = insert(Users).values(**data).returning(Users.__table__.columns) diff --git a/app/main.py b/app/main.py index e66662d..ede4ecb 100644 --- a/app/main.py +++ b/app/main.py @@ -1,5 +1,4 @@ from fastapi import FastAPI -from fastapi.staticfiles import StaticFiles from fastapi.middleware.cors import CORSMiddleware from app.users.router import router as user_router diff --git a/app/users/router.py b/app/users/router.py index 98d90be..fedb694 100644 --- a/app/users/router.py +++ b/app/users/router.py @@ -1,3 +1,4 @@ +import asyncio from random import randrange from fastapi import APIRouter, Depends, status @@ -6,7 +7,6 @@ from app.config import settings from app.exceptions import UserNotFoundException, PasswordAlreadyInUseException from app.users.exceptions import ( UserAlreadyExistsException, - IncorrectAuthDataException, PasswordsMismatchException, WrongCodeException, ) @@ -16,7 +16,6 @@ from app.utils.auth import ( get_password_hash, create_access_token, AuthService, - verify_password, decode_confirmation_token ) from app.users.dependencies import get_current_user @@ -167,6 +166,7 @@ async def login_user(user_data: SUserLogin, uow=Depends(UnitOfWork)): response_model=SUserResponse, ) async def get_user(current_user: SUser = Depends(get_current_user)): + await asyncio.sleep(10) return current_user diff --git a/app/utils/auth.py b/app/utils/auth.py index 06b6df9..520d46f 100644 --- a/app/utils/auth.py +++ b/app/utils/auth.py @@ -3,7 +3,6 @@ from datetime import datetime, timedelta, UTC from cryptography.fernet import Fernet from jose import jwt from passlib.context import CryptContext -from pydantic import EmailStr from app.config import settings from app.exceptions import ( diff --git a/tests/integration_tests/users_api_test.py b/tests/integration_tests/users_api_test.py index a071cc8..e19ce88 100644 --- a/tests/integration_tests/users_api_test.py +++ b/tests/integration_tests/users_api_test.py @@ -1,9 +1,6 @@ import pytest from httpx import AsyncClient -from app.services.user_service import UserService -from app.utils.auth import verify_password - async def test_get_users(ac: AsyncClient): response = await ac.get("/users")