File size: 2,620 Bytes
4304c6d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
from core.app.entities.app_invoke_entities import InvokeFrom
from core.workflow.entities.variable_pool import VariablePool
from core.workflow.nodes.tool.tool_node import ToolNode
from models.workflow import WorkflowNodeExecutionStatus
def test_tool_variable_invoke():
pool = VariablePool(system_variables={}, user_inputs={})
pool.append_variable(node_id='1', variable_key_list=['123', 'args1'], value='1+1')
node = ToolNode(
tenant_id='1',
app_id='1',
workflow_id='1',
user_id='1',
user_from=InvokeFrom.WEB_APP,
config={
'id': '1',
'data': {
'title': 'a',
'desc': 'a',
'provider_id': 'maths',
'provider_type': 'builtin',
'provider_name': 'maths',
'tool_name': 'eval_expression',
'tool_label': 'eval_expression',
'tool_configurations': {},
'tool_parameters': {
'expression': {
'type': 'variable',
'value': ['1', '123', 'args1'],
}
}
}
}
)
# execute node
result = node.run(pool)
assert result.status == WorkflowNodeExecutionStatus.SUCCEEDED
assert '2' in result.outputs['text']
assert result.outputs['files'] == []
def test_tool_mixed_invoke():
pool = VariablePool(system_variables={}, user_inputs={})
pool.append_variable(node_id='1', variable_key_list=['args1'], value='1+1')
node = ToolNode(
tenant_id='1',
app_id='1',
workflow_id='1',
user_id='1',
user_from=InvokeFrom.WEB_APP,
config={
'id': '1',
'data': {
'title': 'a',
'desc': 'a',
'provider_id': 'maths',
'provider_type': 'builtin',
'provider_name': 'maths',
'tool_name': 'eval_expression',
'tool_label': 'eval_expression',
'tool_configurations': {},
'tool_parameters': {
'expression': {
'type': 'mixed',
'value': '{{#1.args1#}}',
}
}
}
}
)
# execute node
result = node.run(pool)
assert result.status == WorkflowNodeExecutionStatus.SUCCEEDED
assert '2' in result.outputs['text']
assert result.outputs['files'] == [] |