Process 1 build 0803262038
This commit is contained in:
@@ -9,6 +9,7 @@ from starlette.requests import Request
|
||||
from backend.app import db
|
||||
from backend.app.config import settings
|
||||
from backend.app.routers import auth as auth_router
|
||||
from backend.app.routers import portal as portal_router
|
||||
from backend.app.security import PASSWORD_POLICY_MESSAGE, validate_password_policy
|
||||
from backend.app.services import password_reset
|
||||
|
||||
@@ -143,3 +144,58 @@ class AuthFlowTests(TempDatabaseMixin, unittest.IsolatedAsyncioTestCase):
|
||||
context.exception.detail,
|
||||
"recipient_email is required and must be a valid email address.",
|
||||
)
|
||||
|
||||
|
||||
class PortalWorkflowTests(TempDatabaseMixin, unittest.TestCase):
|
||||
def test_legacy_request_status_maps_to_workflow(self) -> None:
|
||||
item = {"kind": "request", "status": "in_progress"}
|
||||
serialized = portal_router._serialize_item(item, {"username": "tester", "role": "user"})
|
||||
workflow = serialized.get("workflow") or {}
|
||||
self.assertEqual(workflow.get("request_status"), "approved")
|
||||
self.assertEqual(workflow.get("media_status"), "processing")
|
||||
|
||||
def test_invalid_pipeline_transition_is_rejected(self) -> None:
|
||||
with self.assertRaises(HTTPException) as context:
|
||||
portal_router._validate_pipeline_transition(
|
||||
"approved",
|
||||
"processing",
|
||||
"pending",
|
||||
"pending",
|
||||
)
|
||||
self.assertEqual(context.exception.status_code, 400)
|
||||
|
||||
def test_portal_workflow_filters(self) -> None:
|
||||
db.create_portal_item(
|
||||
kind="request",
|
||||
title="Request A",
|
||||
description="A",
|
||||
created_by_username="alpha",
|
||||
created_by_id=None,
|
||||
status="processing",
|
||||
workflow_request_status="approved",
|
||||
workflow_media_status="processing",
|
||||
)
|
||||
db.create_portal_item(
|
||||
kind="request",
|
||||
title="Request B",
|
||||
description="B",
|
||||
created_by_username="bravo",
|
||||
created_by_id=None,
|
||||
status="pending",
|
||||
workflow_request_status="pending",
|
||||
workflow_media_status="pending",
|
||||
)
|
||||
processing = db.list_portal_items(
|
||||
kind="request",
|
||||
workflow_request_status="approved",
|
||||
workflow_media_status="processing",
|
||||
limit=10,
|
||||
offset=0,
|
||||
)
|
||||
pending_count = db.count_portal_items(
|
||||
kind="request",
|
||||
workflow_request_status="pending",
|
||||
workflow_media_status="pending",
|
||||
)
|
||||
self.assertEqual(len(processing), 1)
|
||||
self.assertEqual(pending_count, 1)
|
||||
|
||||
Reference in New Issue
Block a user