chore: fix all ruff lint errors + format — 0 errors, 306 tests pass
This commit is contained in:
+35
-16
@@ -2,16 +2,14 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
from datetime import datetime, timezone
|
||||
from datetime import UTC, datetime
|
||||
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from tests.conftest import ORIGIN_HEADER, seed_tenant_and_users, login_client
|
||||
from app.core.notifications import create_notification
|
||||
from app.models.notification import Notification
|
||||
from tests.conftest import ORIGIN_HEADER, login_client, seed_tenant_and_users
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -23,22 +21,31 @@ class TestNotifications:
|
||||
seed = await seed_tenant_and_users(db_session)
|
||||
# Create some notifications for admin_a
|
||||
await create_notification(
|
||||
db_session, seed["tenant_a"].id, seed["admin_a"].id,
|
||||
"info", "Read Notif", "Already read",
|
||||
db_session,
|
||||
seed["tenant_a"].id,
|
||||
seed["admin_a"].id,
|
||||
"info",
|
||||
"Read Notif",
|
||||
"Already read",
|
||||
)
|
||||
await db_session.flush()
|
||||
# Mark the first one as read
|
||||
from sqlalchemy import select, update
|
||||
from sqlalchemy import select
|
||||
|
||||
q = select(Notification).where(Notification.title == "Read Notif")
|
||||
result = await db_session.execute(q)
|
||||
first_notif = result.scalar_one()
|
||||
first_notif.read_at = datetime.now(timezone.utc)
|
||||
first_notif.read_at = datetime.now(UTC)
|
||||
await db_session.flush()
|
||||
|
||||
# Create an unread one
|
||||
await create_notification(
|
||||
db_session, seed["tenant_a"].id, seed["admin_a"].id,
|
||||
"info", "Unread Notif", "Not read yet",
|
||||
db_session,
|
||||
seed["tenant_a"].id,
|
||||
seed["admin_a"].id,
|
||||
"info",
|
||||
"Unread Notif",
|
||||
"Not read yet",
|
||||
)
|
||||
await db_session.commit()
|
||||
|
||||
@@ -64,8 +71,12 @@ class TestNotifications:
|
||||
"""AC 25: PATCH /api/v1/notifications/{id}/read -> 200."""
|
||||
seed = await seed_tenant_and_users(db_session)
|
||||
notif = await create_notification(
|
||||
db_session, seed["tenant_a"].id, seed["admin_a"].id,
|
||||
"info", "Test Notif", "Test body",
|
||||
db_session,
|
||||
seed["tenant_a"].id,
|
||||
seed["admin_a"].id,
|
||||
"info",
|
||||
"Test Notif",
|
||||
"Test body",
|
||||
)
|
||||
await db_session.commit()
|
||||
|
||||
@@ -81,12 +92,20 @@ class TestNotifications:
|
||||
"""AC 26: GET /api/v1/notifications/unread-count -> 200 + integer count."""
|
||||
seed = await seed_tenant_and_users(db_session)
|
||||
await create_notification(
|
||||
db_session, seed["tenant_a"].id, seed["admin_a"].id,
|
||||
"info", "Unread 1", "Body 1",
|
||||
db_session,
|
||||
seed["tenant_a"].id,
|
||||
seed["admin_a"].id,
|
||||
"info",
|
||||
"Unread 1",
|
||||
"Body 1",
|
||||
)
|
||||
await create_notification(
|
||||
db_session, seed["tenant_a"].id, seed["admin_a"].id,
|
||||
"info", "Unread 2", "Body 2",
|
||||
db_session,
|
||||
seed["tenant_a"].id,
|
||||
seed["admin_a"].id,
|
||||
"info",
|
||||
"Unread 2",
|
||||
"Body 2",
|
||||
)
|
||||
await db_session.commit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user