refactor(pipelines): address code review - shared get_current_user_id, aria-live, deduplicate user ID logic
- Extract _get_user_id into shared auth.get_current_user_id() used by both pipelines API and the assign-pipeline endpoint in files API - Fix aria-live attribute: use two separate static containers (polite/assertive) instead of dynamic Alpine.js binding for correct screen reader announcements - Fix migration comment to accurately describe batch-mode FK creation - Remove redundant tags parameter from reorder endpoint decorator - Rename _make_file test helper to _make_test_file_record for clarity - Update docs/UserGuide.md and docs/API.md with full Pipelines reference Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -16,7 +16,7 @@ from app.models import FileRecord, Pipeline, PipelineStep
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _make_file(db_session, owner_id=None):
|
||||
def _make_test_file_record(db_session, owner_id=None):
|
||||
"""Insert a minimal FileRecord and return it.
|
||||
|
||||
Default owner_id=None so tests work without an authenticated session.
|
||||
@@ -344,7 +344,7 @@ class TestAssignPipelineToFile:
|
||||
def test_assign_pipeline_to_file(self, client, db_session):
|
||||
"""Assigning a pipeline to a file stores pipeline_id on the record."""
|
||||
# File with no owner so anonymous test session can access it
|
||||
fr = _make_file(db_session, owner_id=None)
|
||||
fr = _make_test_file_record(db_session, owner_id=None)
|
||||
pipeline = client.post("/api/pipelines", json={"name": "Assign Test"}).json()
|
||||
|
||||
r = client.post(f"/api/files/{fr.id}/assign-pipeline?pipeline_id={pipeline['id']}")
|
||||
@@ -358,7 +358,7 @@ class TestAssignPipelineToFile:
|
||||
|
||||
def test_clear_pipeline_from_file(self, client, db_session):
|
||||
"""Passing no pipeline_id clears the assignment."""
|
||||
fr = _make_file(db_session, owner_id=None)
|
||||
fr = _make_test_file_record(db_session, owner_id=None)
|
||||
pipeline = client.post("/api/pipelines", json={"name": "Clearable"}).json()
|
||||
client.post(f"/api/files/{fr.id}/assign-pipeline?pipeline_id={pipeline['id']}")
|
||||
|
||||
@@ -368,7 +368,7 @@ class TestAssignPipelineToFile:
|
||||
|
||||
def test_assign_nonexistent_pipeline_returns_404(self, client, db_session):
|
||||
"""Assigning a non-existent pipeline returns 404."""
|
||||
fr = _make_file(db_session, owner_id=None)
|
||||
fr = _make_test_file_record(db_session, owner_id=None)
|
||||
r = client.post(f"/api/files/{fr.id}/assign-pipeline?pipeline_id=99999")
|
||||
assert r.status_code == 404
|
||||
|
||||
|
||||
Reference in New Issue
Block a user