Skip to content

chore(trainer): add unit tests for discovery tools#82

Open
aastha-m22 wants to merge 1 commit into
kubeflow:mainfrom
aastha-m22:test-discovery-trainer
Open

chore(trainer): add unit tests for discovery tools#82
aastha-m22 wants to merge 1 commit into
kubeflow:mainfrom
aastha-m22:test-discovery-trainer

Conversation

@aastha-m22

Copy link
Copy Markdown

Part of #68 — discovery section.

Covers list_training_jobs, get_training_job, list_runtimes, get_runtime:

  • success paths, runtime/status filtering, the "Succeeded"→"Complete" alias
  • empty-cluster edge cases
  • not-found and generic SDK error handling
  • namespace policy enforcement

Real cluster calls and packages-via-pod polling are out of scope per the issue;
_fetch_packages_via_pod is mocked directly in the one test that exercises
include_packages=True.

Ready for review. I haven't heard back on the issue thread yet, so happy to adjust scope if this overlaps with anything already in progress.

Testing

pytest tests/unit/trainer/test_discovery.py -v → 23 passed
ruff check / ruff format --check → clean

Copilot AI review requested due to automatic review settings July 14, 2026 17:02
@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign electronic-waste for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

Copy link
Copy Markdown

🎉 Welcome to the Kubeflow MCP Server! 🎉

Thanks for opening your first PR! We're happy to have you as part of our community 🚀

Here's what happens next:

  • If you haven't already, please check out our Contributing Guide for repo-specific guidelines and the Kubeflow Contributor Guide for general community standards
  • Our team will review your PR soon! cc @kubeflow/kubeflow-sdk-team

Join the community:

Feel free to ask questions in the comments if you need any help or clarification!
Thanks again for contributing to Kubeflow! 🙏

Signed-off-by: Aastha Mahajan <amahajan1_be23@thapar.edu>
@aastha-m22
aastha-m22 force-pushed the test-discovery-trainer branch from ad8efd4 to a1e885d Compare July 14, 2026 17:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds discovery-tool unit coverage for issue #68.

Changes:

  • Tests job/runtime discovery, filtering, errors, and empty results.
  • Mocks package lookup and namespace policy enforcement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +129 to +141
def test_list_training_jobs_caps_limit_at_max():
client = MagicMock()
client.list_jobs.return_value = [_fake_job(f"job-{i}") for i in range(5)]
with patch(
"kubeflow_mcp.trainer.api.discovery.get_trainer_client_for_namespace",
return_value=client,
):
result = list_training_jobs(limit=10_000)

# All 5 fake jobs returned; the cap only affects slicing, not a crash,
# so this mainly documents that an oversized limit doesn't error.
assert result["success"] is True
assert result["data"]["total"] == 5
# ---------------------------------------------------------------------------


def test_get_training_job_success():
@abhijeet-dhumal

Copy link
Copy Markdown
Member

Waiting for test scaffold to merge first :

@aastha-m22 aastha-m22 changed the title test(trainer): add unit tests for discovery tools chore(trainer): add unit tests for discovery tools Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants