🧪 Add tests for configure_failure_logger - #37
Conversation
…ardization, and utilities
Core infrastructure improvements:
- Smart 'latest' model alias resolution with cost-based tiebreaking
- Standardized error responses with proper HTTP status codes and error.code field
- ProxyExhaustionError for structured credential exhaustion reporting
- TerminalRequestError for non-rotatable errors (404, model not found)
- Per-provider retry count override via MAX_RETRIES_{PROVIDER} env var
- Retry 429 rate_limit errors with backoff instead of rotating
- Cached token pricing in streaming cost calculation
- Split quota stats into current_period and global/lifetime views
- Log rotation for proxy.log and proxy_debug.log (RotatingFileHandler)
- Include latest virtual models in /v1/models endpoint
- Resolve singleton cache pollution for dynamic providers
- Fork-specific README and .gitignore updates
…ased model filtering, and enhanced X-Initiator heuristic
Test suite designed to catch breakage from branch re-organization without sending queries to real LLM providers. Covers all critical integration points that previously broke silently during deployment. Coverage: - Anthropic↔OpenAI format translation & streaming - Error classification (determines retry/rotation behavior) - Request sanitization (prevents 400s from invalid params) - Provider-specific request transforms - Model alias & latest registry parsing - Usage tracking (windows, quota groups, custom caps) - Credential discovery, deduplication, env:// URI - Provider plugin registration & singleton pattern - Proxy endpoint routing & auth All tests use synthetic credentials and mocked HTTP. Runs in ~2.3s. Zero API cost.
…flow Replaces the old manifest-driven multi-branch replay system with a simpler linear commit stack. Changes are made via fixup!/autosquash. Upstream syncs are a single git rebase. Includes: - AGENTS.md: entry point for all AI coding agents - .agent/rules/claude.md: Claude-specific SSH/deployment notes - .agent/rules/llm-proxy.md: container layout and deployment pipeline - .agent/skills/upstream-sync/SKILL.md: sync workflow reference
Custom provider for Google Vertex AI Express Mode API keys that uses x-goog-api-key header authentication against the Vertex AI OpenAI-compatible endpoint. Supports non-streaming and streaming chat completions with automatic model discovery. Models are prefixed as vertex/ (e.g. vertex/gemini-3.1-flash-lite-preview). Env vars: VERTEX_PROJECT, VERTEX_LOCATION, VERTEX_API_KEY_N
Adds unit tests for configure_failure_logger in src/rotator_library/failure_logger.py to verify correct mutation of internal module variables (_configured_logs_dir, _failure_logger) based on various string, Path, and None inputs.
|
👋 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. |
There was a problem hiding this comment.
Code Review
This pull request introduces unit tests for the configure_failure_logger function, covering scenarios such as string paths, Path objects, and resetting the logger state. The review feedback recommends reordering imports to follow PEP 8 standards and implementing a pytest fixture to ensure test isolation by resetting global state after each test execution.
| import pytest | ||
| from pathlib import Path |
There was a problem hiding this comment.
According to PEP 8, standard library imports should be placed before third-party imports. pathlib is part of the standard library, while pytest is a third-party package.
| import pytest | |
| from pathlib import Path | |
| from pathlib import Path | |
| import pytest |
References
- Standard library imports should be placed before third-party imports (PEP 8). (link)
| from rotator_library.failure_logger import configure_failure_logger | ||
|
|
||
|
|
||
| class TestConfigureFailureLogger: |
There was a problem hiding this comment.
The tests in this class modify module-level globals in rotator_library.failure_logger. This can lead to state leakage between tests, potentially causing flaky behavior or affecting other tests in the suite. It is recommended to use a pytest fixture to save and restore the global state after each test.
| class TestConfigureFailureLogger: | |
| class TestConfigureFailureLogger: | |
| @pytest.fixture(autouse=True) | |
| def _reset_state(self): | |
| """Reset the global state of the failure_logger module before and after each test.""" | |
| orig_dir = failure_logger._configured_logs_dir | |
| orig_logger = failure_logger._failure_logger | |
| yield | |
| failure_logger._configured_logs_dir = orig_dir | |
| failure_logger._failure_logger = orig_logger | |
References
- Tests should be isolated and not leave side effects in global state.
|
[Gemini-CLI Review Skill] @jules Reviewing this PR against the checklist and Gemini Code Assist feedback:
|
Thank you for the detailed feedback. I have implemented a cleanup fixture to isolate the global variables, reordered the imports to adhere to PEP 8 standards, and will use the fixup! commit format upon submission. |
Implement isolation via pytest fixture and conform to PEP-8 import ordering.
Implement isolation via pytest fixture and conform to PEP-8 import ordering.
|
[Gemini-CLI Review Skill] Consolidated into the linear commit stack on dev. |
Understood. Acknowledging that this work is consolidated and stopping work on this task. |
🎯 What: The testing gap addressed
Tests were missing for
configure_failure_loggerwhich mutates module-level globals for lazy initialization.📊 Coverage: What scenarios are now tested
Pathobject in the module state.Pathobject sets the correctPathobject in the module state.Noneresets the configured directory state toNone.Noneto force reconfiguration.✨ Result: The improvement in test coverage
The critical setup path for the dedicated JSON failure logger is now thoroughly tested with 4 new dedicated unit tests.
PR created automatically by Jules for task 12616309963845923677 started by @b3nw