mirror of
https://github.com/langgenius/dify.git
synced 2026-04-19 18:27:27 +08:00
Fix workflow graph test regressions
This commit is contained in:
@ -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]
|
||||
|
||||
@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user