🧪 Add tests for get_gemini_oauth_status#166
Conversation
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Reviewer's GuideThis PR adds a new pytest-based unit test module that thoroughly validates the behavior of main.get_gemini_oauth_status across missing-file, missing-token, valid/expired token timing, and exception scenarios by mocking filesystem and time-related calls. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
Next review available in: 5 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Hey - I've left some high level feedback:
- Instead of mutating sys.path in the test file, consider importing
get_gemini_oauth_statusvia a proper package/module structure (e.g.,from router.main import get_gemini_oauth_status) to avoid hidden import-order issues and keep tests isolated from path hacks. - The multiple tests for different expiry scenarios share a lot of setup logic; consider parametrizing these cases with
pytest.mark.parametrizeto reduce duplication and make it easier to add or adjust scenarios.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Instead of mutating sys.path in the test file, consider importing `get_gemini_oauth_status` via a proper package/module structure (e.g., `from router.main import get_gemini_oauth_status`) to avoid hidden import-order issues and keep tests isolated from path hacks.
- The multiple tests for different expiry scenarios share a lot of setup logic; consider parametrizing these cases with `pytest.mark.parametrize` to reduce duplication and make it easier to add or adjust scenarios.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@jules |
|
waiting to trigger gemini reviw |
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
|
Acknowledged. I have rebased the PR against master and verified the tests continue to pass without introducing conflicts. |
Acknowledged. I've rebased the branch on master to resolve any potential conflicts and will now push the updated code. |
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
|
Acknowledged. I have rebased the PR against |
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
|
@gemini review |
There was a problem hiding this comment.
Code Review
This pull request adds a new test suite in router/tests/test_get_gemini_oauth_status.py to cover various scenarios for retrieving Gemini OAuth status, alongside a minor whitespace fix in host_agy_daemon.py. A critical issue was identified where importing main at the module level in the test file can crash the test runner if the configuration file is missing; a workaround using a temporary configuration file was suggested to prevent this.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| router_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) | ||
| if router_path not in sys.path: | ||
| sys.path.insert(0, router_path) | ||
|
|
||
| import main |
There was a problem hiding this comment.
Importing main directly at the module level will trigger the configuration loading logic in router/main.py (lines 261-267). If /config/config.yaml does not exist in the environment where the tests are run (which is common in local development or CI environments), main.py will call sys.exit(1). This causes the test runner to crash immediately during test collection.
To prevent this, we can write a minimal dummy configuration to a temporary file and set the CONFIG_PATH environment variable before importing main.
import tempfile
# Ensure router directory is in sys.path
router_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if router_path not in sys.path:
sys.path.insert(0, router_path)
# Create a temporary config file to prevent main.py from calling sys.exit(1) on import
dummy_config = """
server:
host: "127.0.0.1"
port: 5000
router:
router_model:
api_base: "http://127.0.0.1:8080/v1"
api_key: "local-token"
model: "qwen-0.8b-routing"
classification_rules:
system_prompt: ""
backends: []
"""
with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as tmp:
tmp.write(dummy_config)
tmp_path = tmp.name
os.environ["CONFIG_PATH"] = tmp_path
try:
import main
finally:
try:
os.unlink(tmp_path)
except OSError:
pass|
✅ Action performedReview finished.
|
|
I have successfully rebased the branch against master, verified all tests locally, and submitted the final set of changes which resolves the conflict entirely. |
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
🎯 What: Added comprehensive unit tests for the missing
get_gemini_oauth_statusfunction inrouter/main.pyusingpytestandunittest.mock.📊 Coverage: Mocked
os.path.exists,open,json.load, andtime.timeto reliably test multiple scenarios:✨ Result: Enhanced the reliability and coverage of the metrics dashboard backend functionality.
PR created automatically by Jules for task 15591368961301252072 started by @sheepdestroyer
Summary by Sourcery
Tests: