Skip to content

[Testing] Add unit test suite for backend API endpoints and core modules #63

Open

Description

@SandeepChauhan00

Description

The project currently has zero unit tests or integration tests for any backend module. There is no tests/ directory in backend/ or at the project root, and no test_*.py files exist for any of the core modules (main.py, agents.py, retrieval.py, knowledgespace_api.py, ks_search_tool.py).

Without tests, there is no automated way to verify that new PRs do not break existing functionality. This makes code review harder, increases the risk of regressions, and blocks CI/CD automation.

Verification

I searched the entire project directory and confirmed there are no project-specific test files:

  • ❌ No tests/ directory in project root
  • ❌ No tests/ directory in backend/
  • ❌ No test_*.py files anywhere in backend/
  • ❌ No *.test.tsx or *.test.ts files in frontend/src/
  • ❌ No pytest.ini or conftest.py
  • ❌ No [tool.pytest.ini_options] section in pyproject.toml
  • ❌ No CI workflow running tests in .github/

The only test files in the repository are inside .venv/Lib/site-packages/ and frontend/node_modules/, which belong to third-party libraries, not this project.

Why This Matters

  • No regression protection — PRs could silently break the /health, /api/health, or /api/query endpoints without detection
  • Code review burden — reviewers must manually verify correctness for every change
  • CI/CD blocked — cannot set up automated test pipelines without tests to run
  • Contributor confidence — new contributors hesitate to refactor code when there are no tests to catch breakage
  • Production risk — the existing health check endpoints (/health, /api/health) and the query pipeline have zero test coverage

Proposed Solution

Add a tests/ directory inside backend/ with initial test coverage for the existing endpoints and modules.

Suggested structure:

backend/
└── tests/
├── init.py
├── conftest.py # Shared fixtures (test client, mock env)
├── test_health.py # Tests for /health and /api/health
├── test_query.py # Tests for the query endpoint
└── test_knowledgespace_api.py # Tests for the KS API wrapper

Minimum initial tests should cover:

  1. GET /health returns 200 with {"status": "healthy"}
  2. GET /api/health returns 200 with status and feature flags
  3. Query endpoint exists and accepts POST
  4. Invalid or empty queries return appropriate error codes not 500
  5. Unknown routes return 404

Also add pytest to dev dependencies in pyproject.toml, a [tool.pytest.ini_options] configuration section, and a Run Tests section in the README.

I'd Like to Work on This

I'm happy to submit a PR with the initial test setup and baseline tests for the health endpoints. This would establish the testing foundation that other contributors can build on as the project grows.

Activity

  1. SandeepChauhan00 commented on Feb 15, 2026

    @SandeepChauhan00
    Author

    I've started working on this. The initial test suite covering all backend endpoints is almost ready — will submit the PR soon.

  2. ulekarsiddhant0-boop commented on Feb 17, 2026

    @ulekarsiddhant0-boop
    Contributor

    Hi @SandeepChauhan00 , I am interested in issue #63 . Please assign me this issue so that I resolve the issue. Thank you!

  3. SandeepChauhan00 commented on Feb 17, 2026

    @SandeepChauhan00
    Author

    Thanks! As mentioned on #55, I've already submitted PR #64 for this one as well. Feel free to check the issues tab for unlinked issues you can pick up!

  4. added a commit that references this issue on Apr 22, 2026
    321edd9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions