ActraStride / ActraStride/ABIO

Enhance `mock_clients.py` by Centralizing Mock Model Creation

Đang mở
#22 0 bình luận 0 reaction 1 người được giao Được @ActraStride nhận Xem trên GitHub
Ngôn ngữ chính
Python
Star
2
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Currently, the setup for mock Gemini models used in testing (e.g., in `test_gemini_client.py::TestGeminiClient::test_list_models_success`) is defined directly within the test file itself. This creates a tight coupling between the test logic and the mock data setup.

**Problem:**

1. **Coupling:** Test files become responsible for defining the structure and behavior of mock objects that represent external API responses.
2. **Duplication:** If other test modules need similar mock models, the setup logic might be duplicated, leading to inconsistencies and maintenance overhead.
3. **Organization:** The `mock_clients.py` helper is intended to centralize mock setup, but the model mocking is currently outside its scope.

**Proposed Solution:**

Refactor the `mock_clients.py` module to include functionality for generating and configuring mock Gemini models.

1. **Add Mock Model Data:** Define standard mock model structures (like those used in `test_list_models_success`) within `mock_clients.py`.
2. **Create Helper Function:** Introduce a function (e.g., `get_mock_gemini_models()`) in `mock_clients.py` that returns a pre-configured list of mock `genai.Model` objects.
3. **Update Tests:** Modify `test_gemini_client.py` (and potentially other future tests) to use this new helper function instead of defining mock models inline. The `setup_gemini_mocks` function could potentially be extended to configure the `mock_genai.list_models` return value directly.

**Benefits:**

* **Decoupling:** Test files focus solely on testing client logic, relying on the helper for mock data.
* **Reusability:** Mock model definitions are centralized and easily reusable across different test suites.
* **Maintainability:** Changes to the mock model structure only need to be made in one place (`mock_clients.py`).
* **Consistency:** Ensures all tests use consistently structured mock models.

**Acceptance Criteria:**

* Mock model definitions are removed from `test_gemini_client.py`.
* `mock_clients.py` contains the logic for creating and returning mock Gemini models.
* `test_gemini_client.py` utilizes the new helper functionality from `mock_clients.py` to get mock models for testing `list_models`.
* All relevant tests pass after the refactoring.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.