From 3ec736932e26808e57864b336495cfcdd4181afb Mon Sep 17 00:00:00 2001 From: BukeLy Date: Mon, 17 Nov 2025 18:55:45 +0800 Subject: [PATCH] test: Enhance E2E workspace isolation detection with content verification Add specific content assertions to detect cross-contamination between workspaces. Previously only checked that workspaces had different data, now verifies: - Each workspace contains only its own text content - Each workspace does NOT contain the other workspace's content - Cross-contamination would be immediately detected This ensures the test can find problems, not just pass. Changes: - Add assertions for "Artificial Intelligence" and "Machine Learning" in project_a - Add assertions for "Deep Learning" and "Neural Networks" in project_b - Add negative assertions to verify data leakage doesn't occur - Add detailed output messages showing what was verified Testing: - pytest tests/test_workspace_isolation.py::test_lightrag_end_to_end_workspace_isolation - Test passes with proper content isolation verified --- tests/test_workspace_isolation.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_workspace_isolation.py b/tests/test_workspace_isolation.py index 58942e6c..aee7e1cb 100644 --- a/tests/test_workspace_isolation.py +++ b/tests/test_workspace_isolation.py @@ -857,8 +857,26 @@ relation<|#|>Machine Learning<|#|>Artificial Intelligence<|#|>subset, related fi # Verify they contain different data assert docs_a_content != docs_b_content, "Document storage not properly isolated" + # Verify each workspace contains its own text content + docs_a_str = json.dumps(docs_a_content) + docs_b_str = json.dumps(docs_b_content) + + # Check project_a contains its text and NOT project_b's text + assert "Artificial Intelligence" in docs_a_str, "project_a should contain 'Artificial Intelligence'" + assert "Machine Learning" in docs_a_str, "project_a should contain 'Machine Learning'" + assert "Deep Learning" not in docs_a_str, "project_a should NOT contain 'Deep Learning' from project_b" + assert "Neural Networks" not in docs_a_str, "project_a should NOT contain 'Neural Networks' from project_b" + + # Check project_b contains its text and NOT project_a's text + assert "Deep Learning" in docs_b_str, "project_b should contain 'Deep Learning'" + assert "Neural Networks" in docs_b_str, "project_b should contain 'Neural Networks'" + assert "Artificial Intelligence" not in docs_b_str, "project_b should NOT contain 'Artificial Intelligence' from project_a" + # Note: "Machine Learning" might appear in project_b's text, so we skip that check + print(f"✅ PASSED: LightRAG E2E - Data Isolation") print(f" Document storage correctly isolated between workspaces") + print(f" project_a contains only its own data") + print(f" project_b contains only its own data") else: print(f" Document storage files not found (may not be created yet)") print(f"✅ PASSED: LightRAG E2E - Data Isolation")