From f9baabc9f96804950f68d5c829adc3601ded3719 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Mon, 30 Sep 2024 18:02:37 +0800 Subject: [PATCH] fix(tests): handle invalid variable type for document_extractor_node - Imported StringVariable to properly mock an invalid variable type. - Enhanced test case `test_run_invalid_variable_type` to use StringVariable instead of a plain string. --- .../core/workflow/nodes/test_document_extractor_node.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/tests/unit_tests/core/workflow/nodes/test_document_extractor_node.py b/api/tests/unit_tests/core/workflow/nodes/test_document_extractor_node.py index 60fa41798f..3f169e4257 100644 --- a/api/tests/unit_tests/core/workflow/nodes/test_document_extractor_node.py +++ b/api/tests/unit_tests/core/workflow/nodes/test_document_extractor_node.py @@ -6,6 +6,7 @@ from werkzeug.datastructures import FileStorage from core.file import File, FileTransferMethod from core.variables import ArrayFileSegment +from core.variables.variables import StringVariable from core.workflow.entities.node_entities import NodeRunResult from core.workflow.nodes.document_extractor import DocumentExtractorNode, DocumentExtractorNodeData from core.workflow.nodes.document_extractor.document_extractor_node import ( @@ -51,7 +52,9 @@ def test_run_variable_not_found(document_extractor_node, mock_graph_runtime_stat def test_run_invalid_variable_type(document_extractor_node, mock_graph_runtime_state): document_extractor_node.graph_runtime_state = mock_graph_runtime_state - mock_graph_runtime_state.variable_pool.get.return_value = "Not an ArrayFileSegment" + mock_graph_runtime_state.variable_pool.get.return_value = StringVariable( + value="Not an ArrayFileSegment", name="test" + ) result = document_extractor_node._run()