Fix workflow graph test regressions

This commit is contained in:
-LAN-
2026-03-19 22:04:11 +08:00
parent ada4cc1867
commit e92cf38aaf
2 changed files with 13 additions and 10 deletions

View File

@ -12,7 +12,8 @@ from dify_graph.graph_events import NodeRunFailedEvent, NodeRunStartedEvent
def test_build_fallback_failure_event_uses_naive_utc_and_failed_node_run_result(mocker) -> None:
fixed_time = datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC).replace(tzinfo=None)
mocker.patch("dify_graph.graph_engine.worker.naive_utc_now", return_value=fixed_time)
mock_datetime = mocker.patch("dify_graph.graph_engine.worker.datetime")
mock_datetime.now.return_value = fixed_time.replace(tzinfo=UTC)
worker = Worker(
ready_queue=InMemoryReadyQueue(),
@ -75,7 +76,8 @@ def test_worker_fallback_failure_event_reuses_observed_start_time() -> None:
worker._event_queue.put.side_effect = put_side_effect
with patch("dify_graph.graph_engine.worker.naive_utc_now", return_value=failure_time):
with patch("dify_graph.graph_engine.worker.datetime") as mock_datetime:
mock_datetime.now.return_value = failure_time.replace(tzinfo=UTC)
worker.run()
fallback_event = captured_events[-1]
@ -135,7 +137,8 @@ def test_worker_fallback_failure_event_ignores_nested_iteration_child_start_time
worker._event_queue.put.side_effect = put_side_effect
with patch("dify_graph.graph_engine.worker.naive_utc_now", return_value=failure_time):
with patch("dify_graph.graph_engine.worker.datetime") as mock_datetime:
mock_datetime.now.return_value = failure_time.replace(tzinfo=UTC)
worker.run()
fallback_event = captured_events[-1]

View File

@ -1,14 +1,13 @@
from collections.abc import Mapping
from dify_graph.system_variable import SystemVariable
from core.trigger.constants import TRIGGER_PLUGIN_NODE_TYPE
from core.workflow.nodes.trigger_plugin.trigger_event_node import TriggerEventNode
from core.workflow.system_variables import build_system_variables
from dify_graph.entities import GraphInitParams
from dify_graph.entities.graph_config import NodeConfigDict, NodeConfigDictAdapter
from dify_graph.enums import WorkflowNodeExecutionMetadataKey, WorkflowNodeExecutionStatus
from dify_graph.runtime import GraphRuntimeState, VariablePool
from tests.workflow_test_utils import build_test_graph_init_params
from dify_graph.runtime import GraphRuntimeState
from tests.workflow_test_utils import build_test_graph_init_params, build_test_variable_pool
def _build_context(graph_config: Mapping[str, object]) -> tuple[GraphInitParams, GraphRuntimeState]:
@ -18,9 +17,10 @@ def _build_context(graph_config: Mapping[str, object]) -> tuple[GraphInitParams,
invoke_from="debugger",
)
runtime_state = GraphRuntimeState(
variable_pool=VariablePool(
system_variables=SystemVariable(user_id="user", files=[]),
user_inputs={"payload": "value"},
variable_pool=build_test_variable_pool(
variables=build_system_variables(user_id="user", files=[]),
node_id="node-1",
inputs={"payload": "value"},
),
start_at=0.0,
)