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).
- pytest.ini: 'integration' marker, deselected by default; the integration
suite requires a live Qdrant and will only run in the nightly CI job.
- src/indexer.py: move env validation from import time into _validate_config()
called by main() — the module can now be imported without MAILDIR_PATH /
QDRANT_URL / COLLECTION_NAME set, enabling unit tests.
- tests/test_indexer.py: 27 new unit tests, no network and no model:
decode_mime_words (encoded-words utf-8/iso-8859-1, mixed), extract_text_from_html
(tags, scripts), normalize_email_address, parse_email_message with real
EmailMessage objects (plain bodies, attachments detected and excluded from
body, HTML alternative, unknown charset fallback via raw bytes message,
encoded attachment filename), get_recent_keys against a real tmp_path
Maildir (fresh mtime selected, old mtime excluded, colon-suffix keys).
mailbox.Maildir(create=True) does not create cur/new/tmp on Python 3.11 —
the test helper pre-creates them.
- test_search_by_content: format_search_result() does not include
body_text, so check for the expected message_id instead.
- test_search_no_results: vector cosine similarity always returns
nearest neighbors; use a date filter far in the future to
guarantee zero results instead.
- Integration tests for search_emails and read_email against live Qdrant
- Indexes 3 test emails, tests search by content/participant/date
- CI: new 'integration-test' job with qdrant service, runs before build
- Unit test job ignores integration test file
- Unit tests for normalize_email_address, payload_matches_participant,
format_search_result (9 test cases across 3 test classes)
- New 'test' job in CI workflow (runs before build)
- pytest.ini for pythonpath config