Skip to content

tests: add unit tests for api/tools/utils.py#285

Open
jaishree-verma wants to merge 1 commit intojenkinsci:mainfrom
jaishree-verma:tests/utils-unit-tests
Open

tests: add unit tests for api/tools/utils.py#285
jaishree-verma wants to merge 1 commit intojenkinsci:mainfrom
jaishree-verma:tests/utils-unit-tests

Conversation

@jaishree-verma
Copy link

Problem

api/tools/utils.py had zero test coverage as noted in issue #211.

Changes

Added tests/unit/tools/test_utils.py covering all major functions:

  • _min_max_normalize — empty list, equal values, normal range, single value
  • get_inverted_scores — negative scores, invalid weight fallback,
    empty input, chunk ids preserved
  • validate_tool_calls — valid call, invalid tool name, missing param,
    wrong type, params not dict, empty list
  • get_default_tools_call — returns 4 tools, correct names, query passed correctly
  • filter_retrieved_data — matching plugin, no match, case insensitive matching
  • extract_chunks_content — combined text, empty fallback, missing id/text
    skipped, code block placeholder replaced
  • make_placeholder_replacer — returns code block, missing code fallback

Closes #211

- Add tests for _min_max_normalize (empty, equal values, normal range)
- Add tests for get_inverted_scores (negative scores, invalid weight, empty input)
- Add tests for validate_tool_calls (valid, invalid tool, missing param, wrong type)
- Add tests for get_default_tools_call (4 tools, correct names, query passed)
- Add tests for filter_retrieved_data (match, no match, case insensitive)
- Add tests for extract_chunks_content (combined text, fallback, placeholders)
- Add tests for make_placeholder_replacer (returns code, missing code fallback)

Closes jenkinsci#211
@jaishree-verma jaishree-verma requested a review from a team as a code owner March 15, 2026 17:10
@berviantoleo berviantoleo added the tests This PR adds/removes/updates test cases label Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests This PR adds/removes/updates test cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tests] Add unit tests for api/tools/utils.py — currently zero test coverage

2 participants