chore: fix all ruff lint errors + format — 0 errors, 306 tests pass
This commit is contained in:
+12
-5
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
from tests.conftest import ORIGIN_HEADER, seed_tenant_and_users, login_client
|
||||
from tests.conftest import ORIGIN_HEADER, login_client, seed_tenant_and_users
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -21,8 +21,9 @@ class TestAuthLogin:
|
||||
headers=ORIGIN_HEADER,
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert "leocrm_session" in resp.headers.get("set-cookie", "").lower() or \
|
||||
"leocrm_session" in str(resp.cookies)
|
||||
assert "leocrm_session" in resp.headers.get(
|
||||
"set-cookie", ""
|
||||
).lower() or "leocrm_session" in str(resp.cookies)
|
||||
data = resp.json()
|
||||
assert data["email"] == "admin@tenanta.com"
|
||||
assert data["role"] == "admin"
|
||||
@@ -64,7 +65,9 @@ class TestAuthMe:
|
||||
class TestAuthLogout:
|
||||
"""AC 5: logout."""
|
||||
|
||||
async def test_logout_returns_200_and_invalidates_session(self, client: AsyncClient, db_session):
|
||||
async def test_logout_returns_200_and_invalidates_session(
|
||||
self, client: AsyncClient, db_session
|
||||
):
|
||||
"""AC 5: POST /api/v1/auth/logout -> 200, session invalidated."""
|
||||
await seed_tenant_and_users(db_session)
|
||||
await login_client(client, "admin@tenanta.com")
|
||||
@@ -104,6 +107,7 @@ class TestPasswordReset:
|
||||
async def test_password_reset_confirm_valid_token(self, client: AsyncClient, db_session):
|
||||
"""AC 7: POST /api/v1/auth/password-reset/confirm valid token -> 200."""
|
||||
from app.services.auth_service import auth_service
|
||||
|
||||
await seed_tenant_and_users(db_session)
|
||||
raw_token = await auth_service.get_password_reset_token_raw(db_session, "admin@tenanta.com")
|
||||
await db_session.commit()
|
||||
@@ -119,6 +123,7 @@ class TestPasswordReset:
|
||||
async def test_password_reset_confirm_expired_token(self, client: AsyncClient, db_session):
|
||||
"""AC 8: POST /api/v1/auth/password-reset/confirm expired token -> 400."""
|
||||
from app.services.auth_service import auth_service
|
||||
|
||||
await seed_tenant_and_users(db_session)
|
||||
raw_token = await auth_service.create_expired_reset_token(db_session, "admin@tenanta.com")
|
||||
await db_session.commit()
|
||||
@@ -147,8 +152,10 @@ class TestSwitchTenant:
|
||||
initial_tenant = resp.json()["tenant_id"]
|
||||
|
||||
# Get tenant B ID
|
||||
from app.models.tenant import Tenant
|
||||
from sqlalchemy import select
|
||||
|
||||
from app.models.tenant import Tenant
|
||||
|
||||
q = select(Tenant).where(Tenant.slug == "tenant-b")
|
||||
result = await db_session.execute(q)
|
||||
tenant_b = result.scalar_one()
|
||||
|
||||
Reference in New Issue
Block a user