Skip to content

test: Weaviate - increase unit tests coverage - #3798

Draft
julian-risch wants to merge 2 commits into
mainfrom
test/weaviate-unit-coverage
Draft

test: Weaviate - increase unit tests coverage#3798
julian-risch wants to merge 2 commits into
mainfrom
test/weaviate-unit-coverage

Conversation

@julian-risch

Copy link
Copy Markdown
Member

Related Issues

Proposed Changes:

  • _filters.py was at 41% with its whole operator table untested. Cover every comparison and logical operator, the is_none rewrites, ISO date normalisation, and the De Morgan rewrite that stands in for NOT. The tests compare a description of the filter tree, since Weaviate's composite filters have no __eq__.
  • Cover _clean_connection_settings, _compute_field_unique_values and _to_data_object/_to_document, plus the metadata-info family, write/delete/update and the retrieval methods, by injecting a mock collection.
  • Client construction is left to the integration tests.

How did you test it?

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes — n/a
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test:.

@github-actions github-actions Bot added integration:weaviate type:documentation Improvements or additions to documentation labels Aug 16, 2026
@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Coverage report (weaviate)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/weaviate/src/haystack_integrations/document_stores/weaviate
  _filters.py
  document_store.py
Project Total  

This report was generated by python-coverage-comment-action

Cover the code paths that were only reachable through the
integration-marked tests, which the unit coverage badge excludes.

_filters.py went from 41% to 100%. Its whole operator table was untested:
_handle_date, _contains, _match_no_document and validate_filters had no
references anywhere. These filters are built entirely client-side, so no
Weaviate server is involved:

- every comparison operator, the is_none rewrites for None values, the
  extra is_none clause != needs so documents missing the property still
  match, ISO date normalisation, and every FilterError path
- AND, OR, nesting, and the De Morgan rewrite that stands in for NOT

Because Weaviate's composite filters have no __eq__, the tests compare a
description of the filter tree, so each one states the whole expected
filter instead of poking at attributes.

For document_store.py, the collection-backed methods are driven by
injecting a mock collection, which the collection properties return
as-is: _clean_connection_settings, _compute_field_unique_values,
_to_data_object/_to_document (blob base64, named vectors, datetimes,
bm25 score vs embedding certainty), the metadata-info family, filtered
and unfiltered queries, write for every DuplicatePolicy, delete and
delete_all including batching, update_by_filter, the three retrieval
methods, the DocumentStoreError wrapping, and every async twin.

Client construction is deliberately left to the integration tests.

Unit coverage: 47% -> 95%.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@julian-risch
julian-risch force-pushed the test/weaviate-unit-coverage branch from a275ed0 to 94dc0ab Compare August 18, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:weaviate type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant