Skip to content

Fix: Moved pwhtool tests into tests dir @hruico#847

Merged
VaibhavUpreti merged 3 commits intoTracer-Cloud:mainfrom
hruico:issue/move-pwhtool-to-test
Apr 27, 2026
Merged

Fix: Moved pwhtool tests into tests dir @hruico#847
VaibhavUpreti merged 3 commits intoTracer-Cloud:mainfrom
hruico:issue/move-pwhtool-to-test

Conversation

@hruico
Copy link
Copy Markdown

@hruico hruico commented Apr 24, 2026

Fixes #842

Describe the changes you have made in this PR -

  • Refactored the test suite by migrating test functions from tool_test.py to tests/tools/test_prefect_worker_health_tool.py.

Screenshots of the UI changes (If any) -

  • None

Code Understanding and AI Usage

Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?

  • No, I wrote all the code myself
  • Yes, I used AI assistance (continue below)

If you used AI assistance:

  • I have reviewed every single line of the AI-generated code
  • I can explain the purpose and logic of each function/component I added
  • I have tested edge cases and understand how the code handles them
  • I have modified the AI output to follow this project's coding standards and conventions

Explain your implementation approach:

  • I migrated the test functions to consolidate the testing logic. I made only the minimal adjustments necessary to ensure each function executed correctly within the new file structure.
  • I initially considered manually instantiating the tool inside every test method (e.g., tool = PrefectWorkerHealthTool()). However, since there were 16 separate test methods doing the exact same setup, I opted to use a central @pytest.fixture instead. This keeps the tests DRY, makes them more readable, and centralizes the initialization logic in case the tool's signature ever changes.
  • I chose this specific implementation because it drastically reduces boilerplate code across the file, keeping the tests DRY. It also makes the test file far more maintainable.

Checklist before requesting a review

  • I have added proper PR title and linked to the issue
  • I have performed a self-review of my code
  • I can explain the purpose of every function, class, and logic block I added
  • I understand why my changes work and have tested them thoroughly
  • I have considered potential edge cases and how my code handles them
  • If it is a core feature, I have added thorough tests
  • My code follows the project's style guidelines and conventions

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 24, 2026

Greptile Summary

This PR consolidates PrefectWorkerHealthTool tests by deleting the co-located tool_test.py and migrating all tests into tests/tools/test_prefect_worker_health_tool.py, introducing a shared @pytest.fixture to remove per-test boilerplate and adding several new, more-granular test cases alongside the existing ones. The migration itself is clean, but the new tests were added without removing the pre-existing tests that cover the same scenarios, leaving three duplicate pairs in the file.

Confidence Score: 5/5

Safe to merge — the migration is correct, no tests are lost, and the only finding is duplicate test cases (P2).

All findings are P2 style issues. The test logic itself is correct, no functionality is changed, and the old file is cleanly deleted. Duplicate tests are a minor maintenance concern but do not affect correctness or CI reliability.

tests/tools/test_prefect_worker_health_tool.py — three redundant test functions should be removed.

Important Files Changed

Filename Overview
tests/tools/test_prefect_worker_health_tool.py Migrated tests from tool_test.py; adds pytest fixture and richer coverage, but introduces three duplicate test cases that overlap with the pre-existing tests kept in the file.
app/tools/PrefectWorkerHealthTool/tool_test.py Deleted — tests migrated to tests/tools/test_prefect_worker_health_tool.py as intended.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[tool_test.py\nDeleted] -->|tests migrated| B[test_prefect_worker_health_tool.py]
    B --> C[Pre-existing tests\nfrom original file]
    B --> D[New tests\nfrom tool_test.py]
    C --> E[test_is_available_requires_connection_verified]
    C --> F[test_extract_params_maps_fields]
    C --> G[test_run_returns_unavailable_when_no_api_url]
    D --> H[test_is_available_when_connection_verified\n⚠️ overlaps E]
    D --> I[test_is_available_false_without_connection_verified\n⚠️ overlaps E]
    D --> J[test_run_returns_unavailable_without_api_url\n⚠️ overlaps G]
    D --> K[New unique tests\nbatch/worker/metadata/etc.]
Loading

Reviews (1): Last reviewed commit: "improvement using pytest fixture" | Re-trigger Greptile

Comment thread tests/tools/test_prefect_worker_health_tool.py
@rrajan94
Copy link
Copy Markdown
Collaborator

Hey @hruico, I walked through the diff and the migration itself looks good: the old app/tools/PrefectWorkerHealthTool/tool_test.py is fully covered by the new tests in tests/tools/test_prefect_worker_health_tool.py, and CI is green ✅

There are a few redundant tests left in the consolidated file though:

  • test_is_available_requires_connection_verified overlaps with the new pair:
    • test_is_available_when_connection_verified
    • test_is_available_false_without_connection_verified
  • test_run_returns_unavailable_when_no_api_url overlaps with:
    • test_run_returns_unavailable_without_api_url
    • test_run_returns_unavailable_for_whitespace_only_api_url

These older tests are now strictly less expressive than the new ones and just add noise. I suggest deleting:

  • test_is_available_requires_connection_verified
  • test_run_returns_unavailable_when_no_api_url

This matches the earlier Greptile note about duplicate coverage. After that small cleanup, we can rely on CI and merge 👍

{"name": "worker-3", "status": "UNHEALTHY", "last_heartbeat_time": "2026-04-05T09:00:00Z"},
]
mock_client = MagicMock()
mock_client.__enter__ = MagicMock(return_value=mock_client)
Copy link
Copy Markdown
Member

@VaibhavUpreti VaibhavUpreti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, thanks for contributing @hruico , merging this for velocity. I'll fix the reviews on main

@VaibhavUpreti VaibhavUpreti merged commit 4bdf6e3 into Tracer-Cloud:main Apr 27, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move PrefectWorkerHealthTool tests out of app/ and into tests/

4 participants