Добавил слип для теста

This commit is contained in:
urec56 2024-06-18 16:41:31 +05:00
parent 530f298825
commit 815bdd6704
9 changed files with 9 additions and 20 deletions

View file

@ -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.

View file

@ -1,5 +1,3 @@
import logging
import websockets
from fastapi import WebSocket, WebSocketDisconnect, Depends

View file

@ -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 запроса

View file

@ -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 = (

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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 (

View file

@ -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")