Skip to content

test: run Weaviate serde and conversion tests in the unit job - #3955

Open
dudanogueira wants to merge 4 commits into
deepset-ai:mainfrom
dudanogueira:test/weaviate-unit-job-coverage
Open

dudanogueira wants to merge 4 commits into
deepset-ai:mainfrom
dudanogueira:test/weaviate-unit-job-coverage

Conversation

@dudanogueira

Copy link
Copy Markdown
Contributor

Related Issues

  • None.

Proposed Changes:

Stacked on #3954 — the diff here is the second commit only; please merge that one first.

TestWeaviateDocumentStore carries a class-level @pytest.mark.integration, so every test inside it is excluded from hatch run test:unit. Seven of them need no running Weaviate: they either patch the client or exercise pure functions.

The consequence is that the unit coverage number posted on every PR — and the weaviate badge in the repo README — never accounted for to_dict(), from_dict(), _to_data_object() or _to_document(). A regression in any of them could only be caught by the integration job.

This moves those seven into a new unmarked TestWeaviateDocumentStoreSerde class:

  • test_connection
  • test_to_dict
  • test_to_dict_and_from_dict_preserves_grpc_settings
  • test_from_dict
  • test_to_data_object
  • test_to_document
  • test_schema_class_name_conversion_preserves_pascal_case

The marker itself is load-bearing and stays: the document_store fixture talks to a live server and the class inherits five haystack.testing suites. Extracting the seven is a much smaller and safer change than removing the class marker and re-marking the remaining ~40 methods individually.

How did you test it?

No test bodies change; this is a pure relocation. The counts confirm it: unit selection goes from 87 to 94 and integration from 187 to 180, with the total unchanged at 274.

hatch run test:unit (94 passed), hatch run test:integration (179 passed, 1 skipped), hatch run fmt-check and hatch run test:types all pass.

Notes for the reviewer

git diff renders this as a large shuffle because the new class is inserted above the existing one. git diff --color-moved or reviewing with whitespace-insensitive move detection makes it much easier to read.

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title

@dudanogueira
dudanogueira requested a review from a team as a code owner September 14, 2026 17:55
@dudanogueira
dudanogueira requested review from julian-risch and removed request for a team September 14, 2026 17:55
@CLAassistant

CLAassistant commented Sep 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @dudanogueira, thanks for your interest in contributing to Haystack! 🙏

⚠️ You currently have 4 open pull requests in this repository (#3957, #3956, #3954 and this one). Our review capacity is limited, so please hold off opening more PRs until we've had a chance to review your first 2 open PRs. This helps us give each contribution the attention it deserves. Thank you!

This is an automated message to help us keep the review queue healthy.

@github-actions

github-actions Bot commented Sep 14, 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
  document_store.py
Project Total  

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

Weaviate tracks client integration usage via the
X-Weaviate-Client-Integration header (weaviate/weaviate#10535). Tag the
connection with "haystack-python/<version>" so weaviate-haystack adoption
shows up in Weaviate telemetry.

The header is merged into `additional_headers` at client construction, so
it reaches both the HTTP and the gRPC transport, on all four connection
paths (sync/async x Weaviate Cloud/custom). The alternative,
`client.integrations.configure()`, relies on a private `_IntegrationConfig`
and on the Weaviate Cloud path runs after `connect_to_weaviate_cloud()` has
already built the httpx client, which would drop the HTTP header.

A user supplied value for the same header always wins, so it can be
overridden or suppressed via `additional_headers`. The merged headers are
not stored on the instance, so `to_dict()` keeps serializing only what the
user passed and a serialized pipeline does not bake in the version of
weaviate-haystack that wrote it.

The version is read at runtime via importlib.metadata with an "unknown"
fallback, mirroring the existing `_attribution_header()` helper in the
perplexity integration.
`TestWeaviateDocumentStore` carries a class-level `@pytest.mark.integration`,
so every test inside it was excluded from `hatch run test:unit`. Seven of
them need no running Weaviate: they either patch the client or exercise pure
functions. As a result the unit coverage number posted on every PR, and the
badge in the repo README, never accounted for `to_dict()`, `from_dict()`,
`_to_data_object()` or `_to_document()`, and a regression in any of them
could only be caught by the integration job.

Move those seven into a new unmarked `TestWeaviateDocumentStoreSerde` class:
test_connection, test_to_dict, test_to_dict_and_from_dict_preserves_grpc_settings,
test_from_dict, test_to_data_object, test_to_document and
test_schema_class_name_conversion_preserves_pascal_case.

No test body changes; this is a pure relocation. Unit selection goes from 87
to 94 and integration from 187 to 180, with the total unchanged at 274.
julian-risch and others added 2 commits September 22, 2026 17:00
Merging origin/main into this branch (0f1247e) left the block of
X-Weaviate-Client-Integration header tests in test_document_store.py
twice, byte-for-byte identical. Python silently lets the second
definition shadow the first, so the tests still ran, but ruff flags
each redefinition as F811 and the lint step failed CI with 5 errors:

- test_client_sends_integration_header
- test_async_client_sends_integration_header
- test_user_supplied_integration_header_wins
- test_integration_header_value_falls_back_to_unknown_version
- test_integration_header_is_not_serialized

Remove the second copy. No test coverage changes: each test is still
defined once, lint passes and the unit suite passes (94 tests).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

4 participants