-
Notifications
You must be signed in to change notification settings - Fork 293
Add e2e pytest test for rag command #2260
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
Conversation
Reviewer's GuideAdds a new pytest-based end-to-end test suite for the File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary of ChangesHello @telemaco, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the testing infrastructure by migrating the existing Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Hey - I've found 2 issues, and left some high level feedback:
- In
test_run_dry_runthe parametrizedmodelargument is never used andOLLAMA_MODELis always passed tocheck_output, which makes themodelparameter misleading; either usemodelin the command or remove it from the parametrization. - In
test_rag_dry_run_with_file_urithe raw f-string mixes double quotes aroundREADME.mdinside a double-quoted f-string, which is invalid syntax; switch the inner quotes to single quotes or build the path in a separate variable before interpolating it into the regex.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `test_run_dry_run` the parametrized `model` argument is never used and `OLLAMA_MODEL` is always passed to `check_output`, which makes the `model` parameter misleading; either use `model` in the command or remove it from the parametrization.
- In `test_rag_dry_run_with_file_uri` the raw f-string mixes double quotes around `README.md` inside a double-quoted f-string, which is invalid syntax; switch the inner quotes to single quotes or build the path in a separate variable before interpolating it into the regex.
## Individual Comments
### Comment 1
<location> `test/e2e/test_rag.py:92-93` </location>
<code_context>
+ file_path.touch()
+ file_uri = file_path.as_uri()
+
+ result = ctx.check_output(RAG_DRY_RUN + [file_uri, RAG_MODEL])
+ assert re.search(fr".*-v {Path(ctx.workspace_dir) / "README.md"}:/docs/README.md:ro", result)
+
+
</code_context>
<issue_to_address>
**issue (bug_risk):** The f-string in this assertion is syntactically invalid due to nested double quotes.
`fr"... {Path(ctx.workspace_dir) / "README.md"} ..."` is invalid because the inner `"README.md"` closes the outer string. Use different quotes or build the path first, for example:
```python
target = Path(ctx.workspace_dir) / "README.md"
result = ctx.check_output(RAG_DRY_RUN + [file_uri, RAG_MODEL])
assert re.search(fr".*-v {target}:/docs/README.md:ro", result)
```
This avoids the syntax error so the test can run.
</issue_to_address>
### Comment 2
<location> `test/e2e/test_rag.py:19-28` </location>
<code_context>
+@pytest.mark.parametrize(
</code_context>
<issue_to_address>
**issue (testing):** The `model` parameter in `test_run_dry_run` is unused; the test always uses `OLLAMA_MODEL`.
In the parametrized test, `model` is in the signature but the command always uses `OLLAMA_MODEL`, so the parametrization has no effect and is misleading. Either remove `model` from the params and signature if you always want `OLLAMA_MODEL`, or use it in the command:
```python
result = ctx.check_output(RUN_DRY_RUN + params + [model])
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Code Review
This pull request does a great job of adding comprehensive e2e tests for the rag command, migrating from the old BATS test. The new tests cover various scenarios including dry-runs, different input types, and error handling, which significantly improves test coverage.
I've made a few suggestions to improve the readability of assertions and remove a redundant test case. Overall, this is a solid contribution.
b22330d to
4703ead
Compare
|
@olliewalsh I think we have here a new path inconsistency on windows |
8f88c99 to
b1ee331
Compare
|
PTAL @olliewalsh . I've declared as xfail the windows ones. The PR is ready. |
eb43c73 to
b8fc1ca
Compare
- Migrate to e2e pytest the `test/system/070-rag.bats` bat test. Signed-off-by: Roberto Majadas <rmajadas@redhat.com>
b8fc1ca to
cf7f78c
Compare
olliewalsh
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
test/system/070-rag.batsbat test.Summary by Sourcery
Add end-to-end pytest coverage for the
ragcommand, including dry-run behavior and error handling for various inputs and container engines.Enhancements:
Tests:
ramalama ragandrun --ragdry-run behavior across HTTP, file, and folder inputs, including debug mode.ragexecution with multiple sources and clean up the generated RAG image after the run.