Skip to content

test : add unit tests for _serialize_workflow pure helper #1213

Description

@tmdeveloper007

Summary of What Needs to be Done:
The backend/secuscan/routes.py module exposes _serialize_workflow, a pure helper that transforms a workflow database row dict into the JSON shape consumed by the frontend. It handles the steps_json field (parsing or using empty list on bad JSON), the queued_task_ids list, and assembles the full response dict with id, name, owner_id, enabled, schedule_seconds, last_run_at, steps, and queued_task_ids. No dedicated unit tests cover this function despite it being used in the workflow list and detail endpoints.

Changes that Need to be Made:
Add a new test file testing/backend/unit/test_routes_serialize_workflow.py that directly tests:

  • _serialize_workflow with a complete row (all fields present, steps_json is a list)
  • _serialize_workflow with steps_json as invalid JSON string (should parse as empty list)
  • _serialize_workflow with steps_json as valid JSON string
  • _serialize_workflow with None steps_json (treated as empty list)
  • _serialize_workflow with queued_task_ids provided vs None
  • _serialize_workflow with missing optional fields (enabled=None, schedule_seconds=None)

Import _serialize_workflow from backend.secuscan.routes directly.

Impact that it would Provide:
Prevents regressions in the workflow list/detail API responses. A bug in steps_json parsing or queued_task_ids assembly would silently corrupt the frontend workflow UI.

Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions