Skip to content

test : add unit tests for health_check and root endpoint functions #2273

Description

@tmdeveloper007

Summary of What Needs to be Done:
Add unit tests for the health_check and root endpoint functions in backend/secuscan/main.py. These are FastAPI route handlers that can be tested in isolation by constructing a minimal FastAPI app or by testing them as async functions with mocked dependencies.

Changes that Need to be Made:
Create testing/backend/unit/test_main_endpoints.py (standalone unit tests) covering:

  1. health_check():

    • Returns a JSONResponse with status field
    • Returns 200 status code
    • Response body contains expected fields (e.g., status, version)
  2. root():

    • Returns an HTMLResponse
    • Response has 200 status code
    • Response body contains expected HTML content

Use FastAPI TestClient or construct minimal app state for testing. Mock any app-level dependencies that are not relevant to these endpoints. Run with --noconftest to avoid the full app initialization.

Import from backend.secuscan.main directly. Do NOT import the full app (which requires all routes to be loaded).

Impact that it would Provide:

  • Reliability: Ensures health check and root endpoints return expected responses
  • Testing: Adds coverage for main.py which currently has no unit tests
  • Maintainability: Documents the expected API surface for these endpoints

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