From 00403191f526711153e5b31e14e752eda035ba6f Mon Sep 17 00:00:00 2001 From: "MH.Dmitrii" Date: Wed, 29 Jul 2026 00:44:14 +0300 Subject: [PATCH] integrated tests --- pyproject.toml | 2 ++ tests/integrated/test_auth.py | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1ba7a6c..5501c2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,8 @@ build-backend = "poetry.core.masonry.api" omit = [ "*/models/*", "*/migrations/*", + "*/database/*", + "*/errors/*", "__init__.py", "*/docker/*" ] diff --git a/tests/integrated/test_auth.py b/tests/integrated/test_auth.py index 4631333..88d059c 100644 --- a/tests/integrated/test_auth.py +++ b/tests/integrated/test_auth.py @@ -1,8 +1,10 @@ from types import SimpleNamespace -from uuid import uuid4 +from uuid import UUID, uuid4 import allure import pytest +from fastapi import HTTPException +from pydantic import ValidationError from src.service.auth.auth import CurrentUser from src.service.auth.jwt import Jwt @@ -44,4 +46,21 @@ class TestAuth: assert test_result.email==user_data.email assert test_result.direct_permissions==user_data.direct_permissions assert test_result.group==user_data.group - \ No newline at end of file + + + @pytest.mark.parametrize("user_data, uuid, expected_exception",[ + (SimpleNamespace(first_name="test",last_name="test",middle_name="test",email="d@d.d",direct_permissions=[],group=[],status=False), uuid4(), HTTPException), + (SimpleNamespace(first_name="test",last_name="test",middle_name="test",email="d@d.d",direct_permissions=[],group=[],status=True),1234, HTTPException), + (SimpleNamespace(status=True),uuid4(), ValidationError) + ]) + def test_get_current_user_negative(self,current_user_service:CurrentUser, jwt_service:Jwt, monkeypatch, user_data:SimpleNamespace, expected_exception, uuid)->None: + + with allure.step("create token"): + + token=jwt_service.create_access_token({"sub":str(uuid)}) + + + with allure.step("test get_current_user_with_fake_token"), pytest.raises(expected_exception): + + monkeypatch.setattr(current_user_service.crud_db_actions, "get_user_by_id", lambda user:user_data) + current_user_service.get_current_user(token)