Skip to content

Add unit tests for hash utils, ID generation, and reranker utils#5

Merged
fbmz-improving merged 1 commit intomainfrom
feature/adding-unit-tests-graph-node-ids
Feb 19, 2026
Merged

Add unit tests for hash utils, ID generation, and reranker utils#5
fbmz-improving merged 1 commit intomainfrom
feature/adding-unit-tests-graph-node-ids

Conversation

@fbmz-improving
Copy link
Owner

@fbmz-improving fbmz-improving commented Feb 18, 2026

Summary

Add unit tests for hashing, ID generation, and reranker utilities.

  • test_hash_utils.py (6 tests): covers get_hash determinism, known MD5 vector, uniqueness, unicode input, empty string, and 32-char hex output format
  • test_id_generator.py (22 tests): covers create_source_id, create_chunk_id, create_entity_id, create_topic_id, create_statement_id, create_fact_id, rewrite_id_for_tenant, and tenant isolation across all node types.
  • test_reranker_utils.py (7 tests): covers to_float numpy scalar coercion and score_values_with_tfidf return type, score ordering, and non-negative score guarantees

Test plan

  • Run PYTHONPATH=lexical-graph/src .venv/bin/python -m pytest lexical-graph/tests/unit/ -v — 73 tests pass across all phases
  • Verify no regressions in Phase 1 and Phase 2 tests

- Add test_hash_utils.py: 6 tests covering get_hash determinism,
  known MD5 vector, uniqueness, unicode, empty string, and hex format
- Add test_id_generator.py: 22 tests covering create_source_id,
  create_chunk_id, create_entity_id, create_topic_id,
  create_statement_id, create_fact_id, rewrite_id_for_tenant,
  and tenant isolation across all node types
- Add test_reranker_utils.py: 7 tests covering to_float numpy
  coercion and score_values_with_tfidf return type, ordering,
  and non-negative scores
@acarbonetto
Copy link
Collaborator

Please look into the warnings from the run too:

=============================== warnings summary ===============================
src/graphrag_toolkit/lexical_graph/__init__.py:35
  /home/runner/work/graphrag-toolkit/graphrag-toolkit/lexical-graph/src/graphrag_toolkit/lexical_graph/__init__.py:35: DeprecationWarning: There is no current event loop
    loop = asyncio.get_event_loop()

src/graphrag_toolkit/lexical_graph/utils/llm_cache.py:31
  /home/runner/work/graphrag-toolkit/graphrag-toolkit/lexical-graph/src/graphrag_toolkit/lexical_graph/utils/llm_cache.py:31: PydanticDeprecatedSince20: Using extra keyword arguments on `Field` is deprecated and will be removed. Use `json_schema_extra` instead. (Extra keys: 'desc'). Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.12/migration/
    llm:LLM = Field(desc='LLM whose responses may be cached')

src/graphrag_toolkit/lexical_graph/utils/llm_cache.py:32
  /home/runner/work/graphrag-toolkit/graphrag-toolkit/lexical-graph/src/graphrag_toolkit/lexical_graph/utils/llm_cache.py:32: PydanticDeprecatedSince20: Using extra keyword arguments on `Field` is deprecated and will be removed. Use `json_schema_extra` instead. (Extra keys: 'desc'). Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.12/migration/
    enable_cache:Optional[bool] = Field(desc='Whether the cache is enabled or disabled', default=False)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================== 73 passed, 3 warnings in 0.34s ========================

@fbmz-improving fbmz-improving merged commit afb15e7 into main Feb 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants