ActraStride / ActraStride/ABIO

Enhance `mock_clients.py` by Centralizing Mock Model Creation

Ouverte
#22 0 commentaires 0 réactions 1 personne assignée Réclamée par @ActraStride Voir sur GitHub
Langage dominant
Python
Étoiles
2
Forks
0
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.