-
Notifications
You must be signed in to change notification settings - Fork 13
Test/verify suite template #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test/verify suite template #52
Conversation
Learn moreAll Green is an AI agent that automatically: ✅ Addresses code review comments ✅ Fixes failing CI checks ✅ Resolves merge conflicts |
WalkthroughAdds a new test module implementing an FAQItem dataclass, a MockDataset iterator, a MockAgent with connect/answer, and a FAQAdapter subclass of BaseAdapter; includes a test that runs prepare/execute over the dataset and asserts AdapterOutcome.success and expected output. Changes
Sequence Diagram(s)(Skipped — change is a test addition without a significant new multi-component control-flow feature.) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
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. Comment |
There was a problem hiding this 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
🤖 Fix all issues with AI agents
In @tests/test_suite_template.py:
- Around line 29-44: The test class FAQAdapter has Ruff formatting failures: add
a blank line between each method definition (__init__, prepare, execute) so
there is one blank line separating methods, and fix the AdapterOutcome call in
execute by adding a space after the comma (change
AdapterOutcome(success=success,output=response) to include a space after the
comma). Run ruff format to apply these fixes across the file.
🧹 Nitpick comments (1)
tests/test_suite_template.py (1)
14-14: Consider usingIterator[FAQItem]for__iter__return type.The return type
Generator[FAQItem]works but convention suggestsIterator[FAQItem]for__iter__methods. While generators are iterators so this functions correctly, usingIteratorbetter matches Python's typing conventions for the iterator protocol.♻️ Optional type hint refinement
+from collections.abc import Generator, Iterator ... - def __iter__(self) -> Generator[FAQItem]: + def __iter__(self) -> Iterator[FAQItem]:
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/test_suite_template.py
🧰 Additional context used
🪛 GitHub Actions: CI
tests/test_suite_template.py
[error] 1-1: Ruff format check failed. 1 file would be reformatted. Run 'ruff format' to fix.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test (Python 3.12)
- GitHub Check: Test (Python 3.10)
🔇 Additional comments (3)
tests/test_suite_template.py (3)
7-10: LGTM!Clean dataclass definition appropriate for the test scenario.
18-27: LGTM!The mock agent implementation is appropriately simple for testing purposes. The string-matching logic in
answer()is intentionally basic and sufficient for this test scenario.
46-61: LGTM!The test function correctly verifies the FAQAdapter flow from the documentation template. It follows good test structure (setup, execute, assert) and validates the happy path as intended by the PR objectives. The assertions appropriately check both the success flag and output content.
There was a problem hiding this 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
🤖 Fix all issues with AI agents
In @tests/test_suite_template.py:
- Around line 45-52: The execute method signature violates BaseAdapter: change
the method to match BaseAdapter by declaring def execute(self, case:
DatasetCase, trace: TraceLog) -> AdapterOutcome (or make trace: TraceLog = None
if optional), import TraceLog and DatasetCase from their module, and replace
uses of the old input_data: FAQItem with case (e.g., extract the question and
expected answer from case where you previously used
input_data.question/input_data.answer) while keeping the return
AdapterOutcome(success=..., output=...) and still calling self.agent.answer to
produce the response.
🧹 Nitpick comments (1)
tests/test_suite_template.py (1)
65-70: Test will need updating after fixing the signature mismatch.Once the
FAQAdapter.execute()signature is corrected to matchBaseAdapter, this test will need to pass atraceparameter (orNone) when callingadapter.execute().Additionally, consider verifying that the adapter properly conforms to the BaseAdapter interface by checking that it can be used polymorphically:
# Example: verify it works as a BaseAdapter adapter_base: BaseAdapter = FAQAdapter()This would catch signature mismatches at type-checking time.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/test_suite_template.py
🧰 Additional context used
🧬 Code graph analysis (1)
tests/test_suite_template.py (1)
src/agentunit/adapters/base.py (2)
AdapterOutcome(18-25)BaseAdapter(28-69)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test (Python 3.12)
- GitHub Check: Test (Python 3.10)
🔇 Additional comments (3)
tests/test_suite_template.py (3)
1-10: LGTM!The imports are clean and the FAQItem dataclass appropriately models the test data structure.
13-18: LGTM!The MockDataset provides a simple, hardcoded dataset appropriate for unit testing the adapter flow.
21-31: LGTM!The MockAgent implementation correctly simulates agent behavior for the test scenarios, with logic that matches the expected answers in the dataset.
tests/test_suite_template.py
Outdated
| def execute(self, input_data: FAQItem) -> AdapterOutcome: | ||
| # The core logic we want to test | ||
| response = self.agent.answer(input_data.question) | ||
|
|
||
| # Simple exact match check | ||
| success = response == input_data.answer | ||
|
|
||
| return AdapterOutcome(success=success, output=response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Signature mismatch violates BaseAdapter contract.
The execute() method signature does not match the abstract method defined in BaseAdapter. According to the base class (src/agentunit/adapters/base.py), the signature should be:
def execute(self, case: DatasetCase, trace: TraceLog) -> AdapterOutcomeYour implementation is missing the required trace: TraceLog parameter and uses a different parameter name/type (input_data: FAQItem instead of case: DatasetCase). This violates the abstract base class contract and prevents the adapter from being used polymorphically.
🔧 Proposed fix to match BaseAdapter signature
- def execute(self, input_data: FAQItem) -> AdapterOutcome:
+ def execute(self, case: FAQItem, trace: TraceLog | None = None) -> AdapterOutcome:
# The core logic we want to test
- response = self.agent.answer(input_data.question)
+ response = self.agent.answer(case.question)
# Simple exact match check
- success = response == input_data.answer
+ success = response == case.answer
return AdapterOutcome(success=success, output=response)Note: You'll need to import TraceLog from the appropriate module. If the trace parameter isn't needed for this test adapter, you can make it optional with a default of None.
🤖 Prompt for AI Agents
In @tests/test_suite_template.py around lines 45 - 52, The execute method
signature violates BaseAdapter: change the method to match BaseAdapter by
declaring def execute(self, case: DatasetCase, trace: TraceLog) ->
AdapterOutcome (or make trace: TraceLog = None if optional), import TraceLog and
DatasetCase from their module, and replace uses of the old input_data: FAQItem
with case (e.g., extract the question and expected answer from case where you
previously used input_data.question/input_data.answer) while keeping the return
AdapterOutcome(success=..., output=...) and still calling self.agent.answer to
produce the response.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
aviralgarg05
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!

Description
This PR adds a unit test (
tests/test_suite_template.py) that implements theFAQAdapterpattern described indocs/templates/suite_template.py.It verifies that the documentation example correctly implements the
BaseAdapterinterface and produces validAdapterOutcomeobjects.Closes #4
Type of Change
Changes Made
tests/test_suite_template.pywhich:FAQAdapterinheriting fromBaseAdapter.Testing
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.