Skip to content

Add Tests #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Closed

Add Tests #377

wants to merge 11 commits into from

Conversation

evanmschultz
Copy link
Contributor

@evanmschultz evanmschultz commented Apr 18, 2025

Add Testing for Embedder Module

Overview

This PR adds tests for the embedder directory in graphiti-core, increasing it from 0% to 96%. The changes include test suites for all embedder implementations (OpenAI, Gemini, and VoyageAI) as well as the base embedder client.

Key Changes

Project

  • Added pytest-cov and pytest-mock as dev dependencies
  • Added .coveragerc and updated pytest.ini configs
  • Even Better Toml reformatted, prettiered pyproject.toml

Base Embedder Client Tests

  • Added tests for EmbedderClient abstract class
  • Implemented MinimalEmbedderClient for testing inheritance
  • Added type-safe test fixtures and assertions

OpenAI Embedder Tests

  • Test initialization with various configurations
  • Test embedding creation with string and list inputs
  • Test custom client usage
  • Test environment variable fallback for API key
  • Test default configuration behavior

Gemini Embedder Tests

  • Test initialization and configuration
  • Test embedding creation with different input types
  • Test custom model usage
  • Test error handling and edge cases

VoyageAI Embedder Tests

  • Test initialization and configuration
  • Test embedding creation with string and list inputs
  • Test empty input handling
  • Test mixed input type handling
  • Test custom model configuration

Testing Details

  • All tests use pytest fixtures for consistent mock data
  • Async/await patterns properly tested
  • Type hints and annotations added throughout
  • Error cases and edge conditions covered

Impact

  • Test coverage for embedders increased from 0% to 96%

I have read the CLA Document and I hereby sign the CLA


Important

Add comprehensive tests for embedder module, increasing coverage to 96%, and update testing configurations.

  • Testing:
    • Added tests for EmbedderClient abstract class and MinimalEmbedderClient in test_embedder_client.py.
    • Added tests for GeminiEmbedder in test_embedder_gemini.py, covering initialization, custom config, string and list inputs.
    • Added tests for OpenAIEmbedder in test_embedder_openai.py, covering string and list inputs, custom client, default config, and environment variable API key.
    • Added tests for VoyageAIEmbedder in test_embedder_voyage.py, covering initialization, custom config, string and list inputs, empty input, and mixed types.
  • Configuration:
    • Added pytest-cov and pytest-mock as dev dependencies in pyproject.toml.
    • Added .coveragerc for coverage configuration.
    • Updated pytest.ini for test discovery and coverage reporting.
  • Misc:
    • Reformatted pyproject.toml for consistency.

This description was created by Ellipsis for 8c2f234. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to 8c2f234 in 1 minute and 45 seconds

More details
  • Looked at 859 lines of code in 8 files
  • Skipped 1 files when reviewing.
  • Skipped posting 7 drafted comments based on config settings.
1. .coveragerc:5
  • Draft comment:
    Typo in main condition; use "if name == 'main':".
  • Reason this comment was not posted:
    Marked as duplicate.
2. pytest.ini:21
  • Draft comment:
    Typo in main condition; use "if name == 'main':".
  • Reason this comment was not posted:
    Marked as duplicate.
3. .coveragerc:5
  • Draft comment:
    The exclusion pattern for the main guard appears malformed. Consider using the proper regex, e.g. "if name == 'main':".
  • Reason this comment was not posted:
    Marked as duplicate.
4. pytest.ini:21
  • Draft comment:
    The exclusion pattern for the main guard is repeated here and is malformed. It likely should be "if name == 'main':".
  • Reason this comment was not posted:
    Marked as duplicate.
5. tests/embedder/test_embedder_gemini.py:147
  • Draft comment:
    The test wraps the list input in an extra list. Confirm this behavior is intended and document it if so.
  • Reason this comment was not posted:
    Confidence changes required: 80% <= threshold 80%
    None
6. tests/embedder/test_embedder_voyage.py:175
  • Draft comment:
    Mixed-type inputs like an integer (123) are being converted to a string. Confirm that this conversion aligns with the desired behavior and consider documenting it.
  • Reason this comment was not posted:
    Confidence changes required: 80% <= threshold 80%
    None
7. tests/embedder/test_embedder_openai.py:159
  • Draft comment:
    Patching of environment variables using mocker.patch.dict may affect parallel tests. Consider using a dedicated fixture to manage environment variables safely.
  • Reason this comment was not posted:
    Confidence changes required: 70% <= threshold 80%
    None

Workflow ID: wflow_oNNclNnBMJVthzcg


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

limitations under the License.
"""

# Running tests: pytest -xvs tests/embedder/test_client.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typographical inconsistency: The comment on lines 17-18 mentions tests/embedder/test_client.py, while the actual file name is test_embedder_client.py. Please update the comment to the correct file name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@evanmschultz
Copy link
Contributor Author

This PR partially addresses issue #375 but does not fully resolve it.

evanmschultz and others added 2 commits April 17, 2025 22:19
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
evanmschultz and others added 3 commits April 17, 2025 22:20
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
@evanmschultz
Copy link
Contributor Author

Issues with adding test coverage.

@getzep getzep locked and limited conversation to collaborators Apr 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant