Skip to content

Conversation

@F0rJay
Copy link
Contributor

@F0rJay F0rJay commented Dec 25, 2025

Description

This PR adds missing test cases for DocumentSummaryIndex retrievers. The original test file tests/indices/document_summary/test_retrievers.py only contained an empty test_retrieve_default function with a TODO comment.

Changes Made

  • Added test_retrieve_default: Tests the DEFAULT retriever mode (DocumentSummaryIndexRetriever) which uses LLM-based choice selection to retrieve relevant summaries
  • Added test_retrieve_embedding: Tests the EMBEDDING retriever mode (DocumentSummaryIndexEmbeddingRetriever) which uses embedding similarity to retrieve summaries
  • Implemented proper mocks:
    • mock_llmpredictor_predict_for_choice_select: Mocks LLM predictor for choice select prompts with correct format expected by default_parse_choice_select_answer_fn
    • _get_embeddings: Mocks embedding function for embedding-based retrieval

The tests follow the existing patterns used in other retriever tests (e.g., tests/indices/list/test_retrievers.py) and ensure both retriever modes are properly covered.

Fixes # (N/A - this is a test coverage improvement, not fixing a specific issue)

New Package?

Did I fill in the tool.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • Yes
  • No (Not applicable - this is a test addition)

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • No (Not applicable - test-only change)

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Test improvement (adding missing test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Your pull-request will likely not be merged unless it is covered by some form of impactful unit testing.

  • I added new unit tests to cover this change
  • I believe this change is already covered by existing unit tests

Test Coverage:

  • test_retrieve_default: Tests that the DEFAULT retriever mode correctly retrieves nodes using LLM-based choice selection
  • test_retrieve_embedding: Tests that the EMBEDDING retriever mode correctly retrieves nodes using embedding similarity

Both tests:

  • Create a DocumentSummaryIndex with test documents
  • Use appropriate mocks for LLM predictions and embeddings
  • Verify that retrieved nodes are returned correctly
  • Follow existing test patterns in the codebase

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (Not needed - test-only change)
  • I have added Google Colab support for the newly added notebooks. (Not applicable)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (Pending - need to run tests after dependencies are installed)
  • I ran uv run make format; uv run make lint to appease the lint gods (Pending - will run before final submission)

Additional Notes

This contribution addresses the TODO comment in the original test file and improves test coverage for the DocumentSummaryIndex retrievers. The implementation:

  • Uses proper mock functions that match the expected formats
  • Tests both retriever modes (DEFAULT and EMBEDDING)
  • Follows the existing code style and test patterns
  • Adds meaningful assertions to verify correct behavior

wey-gu and others added 11 commits June 6, 2023 09:31
Still need a followup commit to address backwards compatibility
of graph_store.json from the previous impl.
- Add test_retrieve_default to test DEFAULT retriever mode

- Add test_retrieve_embedding to test EMBEDDING retriever mode

- Use proper mocks for LLM predictor and embeddings

- Follow existing test patterns in the codebase
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Dec 25, 2025
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@logan-markewich
Copy link
Collaborator

The commits seem pretty out of whack here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants