Refactor testing to use Fakes and Dependency Injection#8
Conversation
…sting - Introduced `src/agent_engine_cli/dependencies.py` for `get_client` factory. - Updated `src/agent_engine_cli/main.py` to use `get_client` and consume iterators explicitly. - Created `tests/fakes.py` with `FakeAgentEngineClient` using Vertex AI types. - Refactored `tests/test_main.py` to use `FakeAgentEngineClient` instead of mocks. - Fixed bugs in `main.py` related to iterator emptiness checks and MapField type checking. Co-authored-by: mmontan <2553915+mmontan@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. |
The fakes module import (`from tests.fakes import ...`) requires the tests directory to be a Python package. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add CreateAgentCall dataclass to record create_agent arguments, restoring verification of identity_type and service_account params - Make list_memories return Iterator for consistency with other list methods - Remove verbose thinking-out-loud comments from tests - Clean up unused imports in fakes.py Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This change refactors the CLI to support better testing practices by introducing dependency injection for the
AgentEngineClient. It replaces extensive mocking intests/test_main.pywith a newFakeAgentEngineClientimplementation that mimics the real client using in-memory storage and real Vertex AI objects where possible. This also uncovered and fixed bugs inmain.pywhere iterators were not being consumed before emptiness checks and Protobuf MapFields were being checked strictly againstdict.PR created automatically by Jules for task 12025630112277388695 started by @mmontan