Skip to content

Conversation

@notlesh
Copy link
Contributor

@notlesh notlesh commented Jun 13, 2025

Adds coverage tools and additional tests around agent tools

Summary by CodeRabbit

  • New Features
    • Added new Makefile commands for running tests with coverage and generating HTML coverage reports.
  • Chores
    • Introduced and configured test coverage tools and reporting options in the project settings.
  • Tests
    • Added comprehensive tests for the summarize tool, including handling of different agents and empty summaries.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 13, 2025

Walkthrough

This change introduces test coverage tooling and reporting to the project by updating the Makefile and pyproject.toml with relevant dependencies and configuration. It also adds comprehensive asynchronous unit tests for the summarize tool in the test suite, ensuring its correct instantiation and behavior. Additionally, the GitHub Actions workflow is extended to run coverage tests and upload reports to Codecov.

Changes

File(s) Change Summary
Makefile Added test-coverage and coverage-report targets; updated help descriptions for new targets.
pyproject.toml Added coverage-related dev dependencies; introduced [tool.coverage] configuration for coverage tools.
tests/unit_tests/common/test_tools.py Added TestSummarize class with async tests for the summarize tool, covering instantiation and output.
.github/workflows/checks.yml Extended unit-tests job to run coverage tests and upload coverage reports to Codecov.

Sequence Diagram(s)

sequenceDiagram
    participant Tester
    participant SummarizeTool
    participant Command
    participant ToolMessage

    Tester->>SummarizeTool: Instantiate summarize tool (with agent name)
    Tester->>SummarizeTool: Call summarize tool asynchronously (with summary, tool_call_id)
    SummarizeTool->>Command: Create Command object (with summary)
    SummarizeTool->>ToolMessage: Create ToolMessage (with content, tool_call_id)
    SummarizeTool-->>Tester: Return Command (with ToolMessage)
Loading

Possibly related PRs

  • Moonsong-Labs/ai-nexus#134: Adds an integration test verifying the summarize tool is called in a requirements gatherer flow, complementing these new unit tests.
  • Moonsong-Labs/ai-nexus#180: Refactors the summarize tool into a factory function; this PR’s tests directly relate to that change.

Poem

🐇
With coverage tools and tests anew,
The summarize tool gets its due!
Reports now bloom in HTML,
Ensuring code is tested well.
Rabbits cheer as metrics grow—
Quality, now on show!
📊✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (5)
pyproject.toml (2)

32-35: Avoid duplicating runtime dependencies in dev extra

pytest-asyncio is already declared in the main dependencies list (line 15).
Keeping the same requirement in optional-dependencies.dev is redundant and may lead to version-resolution conflicts if the two specifiers ever diverge.

-    "pytest-asyncio~=0.26.0",

Removing the duplicate keeps the lock-file smaller and guarantees a single source of truth for the version.


107-115: Minor: overlapping omit-globs add noise

"*/tests/*" already blankets the more specific patterns "*/test_*.py" and "*/__pycache__/*".
The duplicates do not break anything, but slimming the list improves readability.

No functional change required; feel free to ignore if you prefer explicit duplication.

Makefile (2)

48-54: HTML report generated twice

test-coverage already produces an HTML report via --cov-report=html.
coverage-report reruns coverage html, doubling runtime and possibly overwriting artefacts with different timestamps.

Consider either:

-test-coverage:
-	uv run pytest tests/unit_tests --cov=src --cov-report=html --cov-report=term
-
-coverage-report:
-	uv run coverage html
-	@echo "Coverage report generated in htmlcov/index.html"
+test-coverage:
+	uv run pytest tests/unit_tests --cov=src --cov-report=html --cov-report=term
+	@echo "HTML coverage report available at htmlcov/index.html"
+
+# Optional: keep this target only if you anticipate generating reports
+# without re-running the test suite.

Streamlines CI minutes and local developer feedback.


131-133: Help text refers to non-existent tests target

The help banner lists:

@echo 'tests                        - run unit tests'

but no tests: rule exists (only test / test-unit). Either add an alias target or drop the line to avoid confusion.

tests/unit_tests/common/test_tools.py (1)

228-268: Brittle console-output assertion

The test asserts an exact 42-char underline:

assert "==========================================" in captured.out

Any formatting tweak (e.g. 40 or 50 =) will break the test while the tool still behaves correctly.

-        assert "==========================================" in captured.out
+        # At least 10 consecutive '=' is enough to prove the banner
+        assert "=" * 10 in captured.out

Keeps intent while future-proofing.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7def88f and 282efd4.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • Makefile (2 hunks)
  • pyproject.toml (2 hunks)
  • tests/unit_tests/common/test_tools.py (2 hunks)
🔇 Additional comments (3)
tests/unit_tests/common/test_tools.py (3)

5-7: Good choice on explicit type imports

Bringing in ToolMessage and Command keeps the assertions type-safe and readable.


270-300: Capsys use is fine, but consider flushing once per invocation

Successive captured = capsys.readouterr() resets the buffer; if future asserts need both agents’ outputs simultaneously this pattern will hide the first printout.
Not critical now—just a heads-up for maintainability.


302-315: Edge-case test looks solid

Validating empty summaries guarantees graceful handling of a common corner case.

Comment on lines +120 to +130
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Exclude-line pattern is incorrect – coverage filter will never match

exclude_lines contains

"if __name__ == .__main__.:",

which is missing the quoting around __main__.

-    "if __name__ == .__main__.:",
+    "if __name__ == '__main__':",

Without the fix, the typical “run as script” guard stays in the coverage report and can artificially drop overall percentages.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == '__main__':",
"if TYPE_CHECKING:",
]
🤖 Prompt for AI Agents
In pyproject.toml around lines 120 to 130, the exclude_lines pattern for the
run-as-script guard is incorrect because it lacks proper quoting around
__main__. Fix this by changing the pattern from "if __name__ == .__main__." to
"if __name__ == '__main__':" so the coverage filter correctly excludes this line
from coverage reports.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/checks.yml (1)

66-72: Review Codecov upload configuration
The step uses fail_ci_if_error: false, which will silence upload failures. If coverage reporting is critical, consider enabling strict CI failure or monitoring upload logs.

-          fail_ci_if_error: false
+          fail_ci_if_error: true
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 282efd4 and 9abe1d3.

📒 Files selected for processing (1)
  • .github/workflows/checks.yml (1 hunks)

Comment on lines +64 to +65
- name: Run tests with coverage
run: make test-coverage
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify test-coverage Makefile target and output
Ensure the Makefile defines a test-coverage target and that it produces a valid coverage report (e.g., coverage.xml) at the repo root. Without it, the Codecov upload will have no data.


🏁 Script executed:

#!/bin/bash
# Check Makefile for test-coverage target
rg -n "^test-coverage:" Makefile

# Confirm coverage.xml generation command exists
rg -n "coverage xml" -g "Makefile" || echo "No 'coverage xml' command found"

Length of output: 166


🏁 Script executed:

#!/bin/bash
# Display the test-coverage target and the commands it runs
rg -n '^test-coverage:' -A 10 Makefile

Length of output: 346


Add XML coverage output for Codecov
The test-coverage target only generates HTML and terminal reports, so no coverage.xml is produced for Codecov to upload. Please update the Makefile to include XML output:

• File: Makefile (around line 48)

test-coverage:
-  	uv run pytest tests/unit_tests --cov=src --cov-report=html --cov-report=term
+  	uv run pytest tests/unit_tests \
+  		--cov=src \
+  		--cov-report=html \
+  		--cov-report=term \
+  		--cov-report=xml

This will emit coverage.xml at the repo root for the Codecov action.

🤖 Prompt for AI Agents
In .github/workflows/checks.yml at lines 64-65, the workflow runs the Makefile
target test-coverage, but the Makefile does not generate a coverage.xml file
needed for Codecov. Update the Makefile around line 48 to modify the
test-coverage target to include generating an XML coverage report (coverage.xml)
at the repo root, typically by adding a command like coverage xml or equivalent,
so Codecov can upload the coverage data correctly.

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.

2 participants