ActraStride / ActraStride/ABIO

Enhance `mock_clients.py` by Centralizing Mock Model Creation

Aberta
#22 0 comentários 0 reações 1 responsável Reivindicada por @ActraStride Ver no GitHub
Linguagem predominante
Python
Estrelas
2
Forks
0
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.