LightRAG/tests
BukeLy 0508ad7a15 fix: prevent offline tests from failing due to missing E2E dependencies
Why this change is needed:
Offline tests were failing with "ModuleNotFoundError: No module named 'qdrant_client'"
because test_e2e_multi_instance.py was being imported during test collection, even
though it's an E2E test that shouldn't run in offline mode. Pytest imports all test
files during collection phase regardless of marks, causing import errors for missing
E2E dependencies (qdrant_client, asyncpg, etc.).

Additionally, the test mocks for PostgreSQL migration were too permissive - they
accepted any parameter format without validation, which allowed bugs (like passing
dict instead of positional args to AsyncPG execute()) to slip through undetected.

How it solves it:
1. E2E Import Fix:
   - Use pytest.importorskip() to conditionally import qdrant_client
   - E2E tests are now skipped cleanly when dependencies are missing
   - Offline tests can collect and run without E2E dependencies

2. Stricter Test Mocks:
   - Enhanced mock_pg_db fixture to validate AsyncPG parameter format
   - Mock execute() now raises TypeError if dict/list passed as single argument
   - Ensures tests catch parameter passing bugs that would fail in production

3. Parameter Validation Test:
   - Added test_postgres_migration_params.py for explicit parameter validation
   - Verifies migration passes positional args correctly to AsyncPG
   - Provides detailed output for debugging parameter issues

Impact:
- Offline tests no longer fail due to missing E2E dependencies
- Future bugs in AsyncPG parameter passing will be caught by tests
- Better test isolation between offline and E2E test suites
- Improved test coverage for migration parameter handling

Testing:
- Verified with `pytest tests/ -m offline -v` - no import errors
- All PostgreSQL migration tests pass (6/6 unit + 1 strict validation)
- Pre-commit hooks pass (ruff-format, ruff)
2025-11-20 02:03:48 +08:00
..
conftest.py Add GitHub CI workflow and test markers for offline/integration tests 2025-11-18 11:36:10 +08:00
README_WORKSPACE_ISOLATION_TESTS.md Fix linting 2025-11-18 08:07:54 +08:00
test_aquery_data_endpoint.py Add GitHub CI workflow and test markers for offline/integration tests 2025-11-18 11:36:10 +08:00
test_base_storage_integrity.py style: fix lint errors (trailing whitespace and formatting) 2025-11-20 01:41:23 +08:00
test_curl_aquery_data.sh Fix linting 2025-10-06 04:57:11 +08:00
test_e2e_multi_instance.py fix: prevent offline tests from failing due to missing E2E dependencies 2025-11-20 02:03:48 +08:00
test_embedding_func.py style: fix lint errors (trailing whitespace and formatting) 2025-11-20 01:41:23 +08:00
test_empty_model_suffix.py fix: correct assert syntax in test_empty_model_suffix to prevent false positives 2025-11-20 01:57:47 +08:00
test_graph_storage.py Add GitHub CI workflow and test markers for offline/integration tests 2025-11-18 11:36:10 +08:00
test_lightrag_ollama_chat.py Rename test classes to prevent warning from pytest 2025-11-18 13:33:05 +08:00
test_migration_complete.py fix: add backward compatibility for Qdrant legacy collection detection 2025-11-20 01:43:47 +08:00
test_postgres_migration.py fix: prevent offline tests from failing due to missing E2E dependencies 2025-11-20 02:03:48 +08:00
test_postgres_migration_params.py fix: prevent offline tests from failing due to missing E2E dependencies 2025-11-20 02:03:48 +08:00
test_postgres_retry_integration.py Add GitHub CI workflow and test markers for offline/integration tests 2025-11-18 11:36:10 +08:00
test_qdrant_migration.py style: fix lint errors (trailing whitespace and formatting) 2025-11-20 01:41:23 +08:00
test_workspace_isolation.py Fix test to use default workspace parameter behavior 2025-11-18 11:51:17 +08:00
test_write_json_optimization.py Add GitHub CI workflow and test markers for offline/integration tests 2025-11-18 11:36:10 +08:00