Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: skip tests if no database run (#28102)
yihonga39b50adbb95
diff --git a/api/tests/unit_tests/core/workflow/graph_engine/test_database_utils.py b/api/tests/unit_tests/core/workflow/graph_engine/test_database_utils.pynew file mode 100644index 00000000000..ae7dd48bb16--- /dev/null+++ b/api/tests/unit_tests/core/workflow/graph_engine/test_database_utils.py@@ -0,0 +1,46 @@+"""+Utilities for detecting if database service is available for workflow tests.+"""++import psycopg2+import pytest++from configs import dify_config+++def is_database_available() -> bool:+ """+ Check if the database service is available by attempting to connect to it.++ Returns:+ True if database is available, False otherwise.+ """+ try:+ # Try to establish a database connection using a context manager+ with psycopg2.connect(+ host=dify_config.DB_HOST,+ port=dify_config.DB_PORT,+ database=dify_config.DB_DATABASE,+ user=dify_config.DB_USERNAME,+ password=dify_config.DB_PASSWORD,+ connect_timeout=2, # 2 second timeout+ ) as conn:+ pass # Connection established and will be closed automatically+ return True+ except (psycopg2.OperationalError, psycopg2.Error):+ return False+++def skip_if_database_unavailable():+ """+ Pytest skip decorator that skips tests when database service is unavailable.++ Usage:+ @skip_if_database_unavailable()+ def test_my_workflow():+ ...+ """+ return pytest.mark.skipif(+ not is_database_available(),+ reason="Database service is not available (connection refused or authentication failed)",+ )diff --git a/api/tests/unit_tests/core/workflow/graph_engine/test_iteration_flatten_output.py b/api/tests/unit_tests/core/workflow/graph_engine/test_iteration_flatten_output.pyindex f2095a8a705..98f344babf6 100644--- a/api/tests/unit_tests/core/workflow/graph_engine/test_iteration_flatten_output.py+++ b/api/tests/unit_tests/core/workflow/graph_engine/test_iteration_flatten_output.py@@ -6,9 +6,11 @@ This module tests the iteration node's ability to:2. Preserve nested array structure when flatten_output=False"""+from .test_database_utils import skip_if_database_unavailablefrom .test_table_runner import TableTestRunner, WorkflowTestCase+@skip_if_database_unavailable()def test_iteration_with_flatten_output_enabled():"""Test iteration node with flatten_output=True (default behavior).@@ -37,6 +39,7 @@ def test_iteration_with_flatten_output_enabled():)+@skip_if_database_unavailable()def test_iteration_with_flatten_output_disabled():"""Test iteration node with flatten_output=False.@@ -65,6 +68,7 @@ def test_iteration_with_flatten_output_disabled():)+@skip_if_database_unavailable()def test_iteration_flatten_output_comparison():"""Run both flatten_output configurations in parallel to verify the difference.