Skip to content

Refactor testing to use Fakes and Dependency Injection#8

Merged
mmontan merged 3 commits intomainfrom
refactor-testing-fakes-12025630112277388695
Feb 11, 2026
Merged

Refactor testing to use Fakes and Dependency Injection#8
mmontan merged 3 commits intomainfrom
refactor-testing-fakes-12025630112277388695

Conversation

@mmontan
Copy link
Collaborator

@mmontan mmontan commented Jan 27, 2026

This change refactors the CLI to support better testing practices by introducing dependency injection for the AgentEngineClient. It replaces extensive mocking in tests/test_main.py with a new FakeAgentEngineClient implementation that mimics the real client using in-memory storage and real Vertex AI objects where possible. This also uncovered and fixed bugs in main.py where iterators were not being consumed before emptiness checks and Protobuf MapFields were being checked strictly against dict.


PR created automatically by Jules for task 12025630112277388695 started by @mmontan

…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>
@google-labs-jules
Copy link
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

mmontan and others added 2 commits February 10, 2026 21:45
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>
@mmontan mmontan merged commit 1255ab9 into main Feb 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant