test: fix collection name mismatch — env wiring centralized in conftest
PR Checks / hadolint (pull_request) Successful in 18s
PR Checks / pytest (pull_request) Successful in 1m59s
Docker Build and Push / test (pull_request) Successful in 2m7s
Docker Build and Push / integration-test (pull_request) Successful in 2m14s
PR Checks / build-test (pull_request) Successful in 2m28s
Docker Build and Push / build (pull_request) Successful in 1m50s
PR Checks / hadolint (pull_request) Successful in 18s
PR Checks / pytest (pull_request) Successful in 1m59s
Docker Build and Push / test (pull_request) Successful in 2m7s
Docker Build and Push / integration-test (pull_request) Successful in 2m14s
PR Checks / build-test (pull_request) Successful in 2m28s
Docker Build and Push / build (pull_request) Successful in 1m50s
Root cause of the CI 404s: test modules mutated os.environ at import time (test_server.py set COLLECTION_NAME='test', test_integration.py 'test_mcp_maildir'). With pytest's alphabetical import order, server.COLLECTION_NAME froze at whichever value was set when server was first imported, while the fixture read os.environ at runtime — often a different name (log proof: fixture created 'test', server queried 'test_mcp_maildir' → 404 on all 6 tests). conftest.py now sets QDRANT_URL/COLLECTION_NAME/EMBEDDING_MODEL_NAME once, before any test module import; env mutation removed from test files. Unit suite still green (43 passed, 6 deselected).
This commit is contained in:
1 parent
ef8fe35da7
commit
679d72288f
3 files changed
+25
-9
No files matched your search
@@ -1,13 +1,14 @@
|
||||
"""Integration tests for mcp-maildir with a real Qdrant instance."""
|
||||
"""Integration tests for mcp-maildir with a real Qdrant instance.
|
||||
|
||||
Env vars (QDRANT_URL, COLLECTION_NAME, EMBEDDING_MODEL_NAME) are set in
|
||||
tests/conftest.py — don't set them here, they must match server.py's
|
||||
import-time snapshot for every module in the session.
|
||||
"""
|
||||
|
||||
import os
|
||||
import uuid
|
||||
import pytest
|
||||
|
||||
os.environ["QDRANT_URL"] = "http://localhost:6333"
|
||||
os.environ["COLLECTION_NAME"] = "test_mcp_maildir"
|
||||
os.environ["EMBEDDING_MODEL_NAME"] = "BAAI/bge-small-en-v1.5"
|
||||
|
||||
from server import get_qdrant_client, get_embedding_model, search_emails, read_email
|
||||
from qdrant_client.http import models
|
||||
|
||||
|
||||
Reference in new issue
Block a user