chore: fix all ruff lint errors + format — 0 errors, 306 tests pass

This commit is contained in:
leocrm-bot
2026-06-29 17:43:56 +02:00
parent 316f323ff4
commit a2452cc04b
81 changed files with 2317 additions and 1128 deletions
+14 -5
View File
@@ -5,12 +5,10 @@ from __future__ import annotations
import pytest
from httpx import AsyncClient
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from tests.conftest import ORIGIN_HEADER, seed_tenant_and_users, login_client
from app.models.audit import AuditLog
from app.models.notification import Notification
from app.models.company import Company
from tests.conftest import ORIGIN_HEADER, login_client, seed_tenant_and_users
@pytest.mark.asyncio
@@ -60,6 +58,7 @@ class TestUserManagement:
await login_client(client, "admin@tenanta.com")
# Get viewer user ID
from app.models.user import User
q = select(User).where(User.email == "viewer@tenanta.com")
result = await db_session.execute(q)
viewer = result.scalar_one()
@@ -76,6 +75,7 @@ class TestUserManagement:
await seed_tenant_and_users(db_session)
await login_client(client, "admin@tenanta.com")
from app.models.user import User
q = select(User).where(User.email == "viewer@tenanta.com")
result = await db_session.execute(q)
viewer = result.scalar_one()
@@ -102,7 +102,9 @@ class TestRoleManagement:
assert "permissions" in data["items"][0]
assert "field_permissions" in data["items"][0]
async def test_create_role_with_custom_permissions_returns_201(self, client: AsyncClient, db_session):
async def test_create_role_with_custom_permissions_returns_201(
self, client: AsyncClient, db_session
):
"""AC 16: POST /api/v1/roles with custom permissions -> 201."""
await seed_tenant_and_users(db_session)
await login_client(client, "admin@tenanta.com")
@@ -110,7 +112,9 @@ class TestRoleManagement:
"/api/v1/roles",
json={
"name": "manager",
"permissions": {"companies": {"read": True, "create": True, "update": True, "delete": True}},
"permissions": {
"companies": {"read": True, "create": True, "update": True, "delete": True}
},
"field_permissions": {"annual_revenue": "read"},
},
headers=ORIGIN_HEADER,
@@ -172,6 +176,7 @@ class TestFieldPermissions:
# Create a user with sales_rep role
from app.core.auth import hash_password
from app.models.user import User, UserTenant
sales_user = User(
tenant_id=seed["tenant_a"].id,
email="sales@tenanta.com",
@@ -213,6 +218,7 @@ class TestAuditLog:
# Check audit_log table
from sqlalchemy import select as sel
q = sel(AuditLog).where(AuditLog.entity_type == "company", AuditLog.action == "create")
result = await db_session.execute(q)
entries = result.scalars().all()
@@ -230,6 +236,7 @@ class TestAuditLog:
assert resp.status_code == 200
from sqlalchemy import select as sel
q = sel(AuditLog).where(AuditLog.entity_type == "company", AuditLog.action == "update")
result = await db_session.execute(q)
entries = result.scalars().all()
@@ -246,6 +253,7 @@ class TestAuditLog:
assert resp.status_code == 204
from sqlalchemy import select as sel
q = sel(AuditLog).where(AuditLog.entity_type == "company", AuditLog.action == "delete")
result = await db_session.execute(q)
entries = result.scalars().all()
@@ -275,6 +283,7 @@ class TestNotificationOnAssign:
# Check notification was created for the new user
from sqlalchemy import select as sel
q = sel(Notification).where(Notification.user_id == new_user_id)
result = await db_session.execute(q)
notifs = result.scalars().all()