Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

Move and run Python SDK integration tests

Edwin Josedb83df1c9617
diff --git a/Makefile b/Makefile
index c4081bc6a..80c07bbdd 100644
--- a/Makefile
+++ b/Makefile
@@ -700,7 +700,7 @@ test-unit: ## Run unit tests only
test-integration: ## Run integration tests (requires infrastructure)
@echo "$(YELLOW)Running integration tests (requires infrastructure)...$(NC)"
@echo "$(CYAN)Make sure to run 'make dev-local' first!$(NC)"
- uv run pytest tests/integration/ -v
+ uv run pytest tests/integration/ --ignore=tests/integration/test_sdk.py -v
test-ci: ensure-rsa-keys ensure-config-dir ## Start infra, run integration + SDK tests, tear down (uses DockerHub images)
@set -e; \
@@ -792,10 +792,7 @@ test-ci: ensure-rsa-keys ensure-config-dir ## Start infra, run integration + SDK
curl -s http://localhost:3000/ >/dev/null 2>&1 && break || sleep 2; \
done; \
echo "$(PURPLE)Running Python SDK integration tests$(NC)"; \
- cd sdks/python && \
- uv sync --extra dev && \
- OPENRAG_URL=http://localhost:3000 uv run pytest tests/test_integration.py -vv -s || TEST_RESULT=1; \
- cd ../..; \
+ SDK_TESTS_ONLY=true OPENRAG_URL=http://localhost:3000 uv run pytest tests/integration/test_sdk.py -vv -s || TEST_RESULT=1; \
echo "$(PURPLE)Running TypeScript SDK integration tests$(NC)"; \
cd sdks/typescript && \
npm install && npm run build && \
@@ -900,10 +897,7 @@ test-ci-local: ensure-rsa-keys ensure-config-dir ## Same as test-ci but builds a
curl -s http://localhost:3000/ >/dev/null 2>&1 && break || sleep 2; \
done; \
echo "$(PURPLE)Running Python SDK integration tests$(NC)"; \
- cd sdks/python && \
- uv sync --extra dev && \
- OPENRAG_URL=http://localhost:3000 uv run pytest tests/test_integration.py -vv -s || TEST_RESULT=1; \
- cd ../..; \
+ SDK_TESTS_ONLY=true OPENRAG_URL=http://localhost:3000 uv run pytest tests/integration/test_sdk.py -vv -s || TEST_RESULT=1; \
echo "$(PURPLE)Running TypeScript SDK integration tests$(NC)"; \
cd sdks/typescript && \
npm install && npm run build && \
@@ -935,7 +929,7 @@ test-sdk: ## Run SDK integration tests (requires running OpenRAG at localhost:30
@echo "$(CYAN)Make sure OpenRAG is running at localhost:3000 (make dev)$(NC)"
@echo ""
@echo "$(PURPLE)Running Python SDK tests...$(NC)"
- cd sdks/python && uv sync --extra dev && OPENRAG_URL=http://localhost:3000 uv run pytest tests/test_integration.py -vv -s
+ SDK_TESTS_ONLY=true OPENRAG_URL=http://localhost:3000 uv run pytest tests/integration/test_sdk.py -vv -s
@echo ""
@echo "$(PURPLE)Running TypeScript SDK tests...$(NC)"
cd sdks/typescript && npm install && npm run build && OPENRAG_URL=http://localhost:3000 npm test
diff --git a/pyproject.toml b/pyproject.toml
index 944467543..d0e226cd9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -45,7 +45,7 @@ dependencies = [
]
[dependency-groups]
-dev = ["pytest>=8", "pytest-asyncio>=0.21.0", "pytest-mock>=3.12.0", "pytest-cov>=4.0.0"]
+dev = ["pytest>=8", "pytest-asyncio>=0.21.0", "pytest-mock>=3.12.0", "pytest-cov>=4.0.0", {path = "sdks/python", editable = true}]
[project.scripts]
openrag = "tui.main:run_tui"
diff --git a/tests/conftest.py b/tests/conftest.py
index 1da7c20f4..ffe80467e 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -26,7 +26,14 @@ async def onboard_system():
This ensures the OpenRAG config is marked as edited and properly initialized
so that tests can use the /settings endpoint.
+
+ Skips in-process backend setup when SDK_TESTS_ONLY=true (SDK tests talk to
+ an already-running external stack and must not wipe its state).
"""
+ if os.environ.get("SDK_TESTS_ONLY") == "true":
+ yield
+ return
+
from pathlib import Path
import shutil
@@ -34,7 +41,7 @@ async def onboard_system():
config_file = Path("config/config.yaml")
if config_file.exists():
config_file.unlink()
-
+
# Clean up OpenSearch data directory to ensure fresh state for tests
opensearch_data_path = Path(os.getenv("OPENSEARCH_DATA_PATH", "./opensearch-data"))
if opensearch_data_path.exists():
diff --git a/sdks/python/tests/test_integration.py b/tests/integration/test_sdk.py
similarity index 100%
rename from sdks/python/tests/test_integration.py
rename to tests/integration/test_sdk.py