Skip to content

[Tests] Add unit tests for schemas.py, expand sanitizer and prompt_builder coverage #321

@JayDS22

Description

@JayDS22

Problem

Three modules have gaps in test coverage.

1. api/models/schemas.py - zero coverage for utility functions

The query-type helpers (is_valid_query_type, str_to_query_type, try_str_to_query_type) and the request validators on ChatRequest and ChatRequestWithFiles have no tests at all.

2. api/prompts/prompt_builder.py - log_context branch untested

The existing four tests all call build_prompt with log_context=None. The LOG_ANALYSIS_INSTRUCTION code path that was added in PR #89 has zero coverage.

3. api/tools/sanitizer.py - most regex patterns untested

Only the password and docker-login patterns are tested. The Bearer token, GitHub token (ghp_), private key block, client_secret, and api_key (colon separator) patterns have no tests.

Proposed fix

  • 22 tests in a new tests/unit/models/test_schemas.py
  • 3 tests appended to tests/unit/prompts/test_prompt_builder.py
  • 5 tests appended to tests/unit/tools/test_sanitizer.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions