integrated tests

This commit is contained in:
2026-07-29 00:44:14 +03:00
parent d24b99b8b0
commit 00403191f5
2 changed files with 23 additions and 2 deletions

View File

@@ -36,6 +36,8 @@ build-backend = "poetry.core.masonry.api"
omit = [
"*/models/*",
"*/migrations/*",
"*/database/*",
"*/errors/*",
"__init__.py",
"*/docker/*"
]

View File

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