|
|
|
|
@ -57,57 +57,62 @@ def test_execute_if_else_result_true():
|
|
|
|
|
pool.add(["start", "null"], None)
|
|
|
|
|
pool.add(["start", "not_null"], "1212")
|
|
|
|
|
|
|
|
|
|
node_config = {
|
|
|
|
|
"id": "if-else",
|
|
|
|
|
"data": {
|
|
|
|
|
"title": "123",
|
|
|
|
|
"type": "if-else",
|
|
|
|
|
"logical_operator": "and",
|
|
|
|
|
"conditions": [
|
|
|
|
|
{
|
|
|
|
|
"comparison_operator": "contains",
|
|
|
|
|
"variable_selector": ["start", "array_contains"],
|
|
|
|
|
"value": "ab",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"comparison_operator": "not contains",
|
|
|
|
|
"variable_selector": ["start", "array_not_contains"],
|
|
|
|
|
"value": "ab",
|
|
|
|
|
},
|
|
|
|
|
{"comparison_operator": "contains", "variable_selector": ["start", "contains"], "value": "ab"},
|
|
|
|
|
{
|
|
|
|
|
"comparison_operator": "not contains",
|
|
|
|
|
"variable_selector": ["start", "not_contains"],
|
|
|
|
|
"value": "ab",
|
|
|
|
|
},
|
|
|
|
|
{"comparison_operator": "start with", "variable_selector": ["start", "start_with"], "value": "ab"},
|
|
|
|
|
{"comparison_operator": "end with", "variable_selector": ["start", "end_with"], "value": "ab"},
|
|
|
|
|
{"comparison_operator": "is", "variable_selector": ["start", "is"], "value": "ab"},
|
|
|
|
|
{"comparison_operator": "is not", "variable_selector": ["start", "is_not"], "value": "ab"},
|
|
|
|
|
{"comparison_operator": "empty", "variable_selector": ["start", "empty"], "value": "ab"},
|
|
|
|
|
{"comparison_operator": "not empty", "variable_selector": ["start", "not_empty"], "value": "ab"},
|
|
|
|
|
{"comparison_operator": "=", "variable_selector": ["start", "equals"], "value": "22"},
|
|
|
|
|
{"comparison_operator": "≠", "variable_selector": ["start", "not_equals"], "value": "22"},
|
|
|
|
|
{"comparison_operator": ">", "variable_selector": ["start", "greater_than"], "value": "22"},
|
|
|
|
|
{"comparison_operator": "<", "variable_selector": ["start", "less_than"], "value": "22"},
|
|
|
|
|
{
|
|
|
|
|
"comparison_operator": "≥",
|
|
|
|
|
"variable_selector": ["start", "greater_than_or_equal"],
|
|
|
|
|
"value": "22",
|
|
|
|
|
},
|
|
|
|
|
{"comparison_operator": "≤", "variable_selector": ["start", "less_than_or_equal"], "value": "22"},
|
|
|
|
|
{"comparison_operator": "null", "variable_selector": ["start", "null"]},
|
|
|
|
|
{"comparison_operator": "not null", "variable_selector": ["start", "not_null"]},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
node = IfElseNode(
|
|
|
|
|
id=str(uuid.uuid4()),
|
|
|
|
|
graph_init_params=init_params,
|
|
|
|
|
graph=graph,
|
|
|
|
|
graph_runtime_state=GraphRuntimeState(variable_pool=pool, start_at=time.perf_counter()),
|
|
|
|
|
config={
|
|
|
|
|
"id": "if-else",
|
|
|
|
|
"data": {
|
|
|
|
|
"title": "123",
|
|
|
|
|
"type": "if-else",
|
|
|
|
|
"logical_operator": "and",
|
|
|
|
|
"conditions": [
|
|
|
|
|
{
|
|
|
|
|
"comparison_operator": "contains",
|
|
|
|
|
"variable_selector": ["start", "array_contains"],
|
|
|
|
|
"value": "ab",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"comparison_operator": "not contains",
|
|
|
|
|
"variable_selector": ["start", "array_not_contains"],
|
|
|
|
|
"value": "ab",
|
|
|
|
|
},
|
|
|
|
|
{"comparison_operator": "contains", "variable_selector": ["start", "contains"], "value": "ab"},
|
|
|
|
|
{
|
|
|
|
|
"comparison_operator": "not contains",
|
|
|
|
|
"variable_selector": ["start", "not_contains"],
|
|
|
|
|
"value": "ab",
|
|
|
|
|
},
|
|
|
|
|
{"comparison_operator": "start with", "variable_selector": ["start", "start_with"], "value": "ab"},
|
|
|
|
|
{"comparison_operator": "end with", "variable_selector": ["start", "end_with"], "value": "ab"},
|
|
|
|
|
{"comparison_operator": "is", "variable_selector": ["start", "is"], "value": "ab"},
|
|
|
|
|
{"comparison_operator": "is not", "variable_selector": ["start", "is_not"], "value": "ab"},
|
|
|
|
|
{"comparison_operator": "empty", "variable_selector": ["start", "empty"], "value": "ab"},
|
|
|
|
|
{"comparison_operator": "not empty", "variable_selector": ["start", "not_empty"], "value": "ab"},
|
|
|
|
|
{"comparison_operator": "=", "variable_selector": ["start", "equals"], "value": "22"},
|
|
|
|
|
{"comparison_operator": "≠", "variable_selector": ["start", "not_equals"], "value": "22"},
|
|
|
|
|
{"comparison_operator": ">", "variable_selector": ["start", "greater_than"], "value": "22"},
|
|
|
|
|
{"comparison_operator": "<", "variable_selector": ["start", "less_than"], "value": "22"},
|
|
|
|
|
{
|
|
|
|
|
"comparison_operator": "≥",
|
|
|
|
|
"variable_selector": ["start", "greater_than_or_equal"],
|
|
|
|
|
"value": "22",
|
|
|
|
|
},
|
|
|
|
|
{"comparison_operator": "≤", "variable_selector": ["start", "less_than_or_equal"], "value": "22"},
|
|
|
|
|
{"comparison_operator": "null", "variable_selector": ["start", "null"]},
|
|
|
|
|
{"comparison_operator": "not null", "variable_selector": ["start", "not_null"]},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
config=node_config,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Initialize node data
|
|
|
|
|
node.init_node_data(node_config["data"])
|
|
|
|
|
|
|
|
|
|
# Mock db.session.close()
|
|
|
|
|
db.session.close = MagicMock()
|
|
|
|
|
|
|
|
|
|
@ -162,33 +167,38 @@ def test_execute_if_else_result_false():
|
|
|
|
|
pool.add(["start", "array_contains"], ["1ab", "def"])
|
|
|
|
|
pool.add(["start", "array_not_contains"], ["ab", "def"])
|
|
|
|
|
|
|
|
|
|
node_config = {
|
|
|
|
|
"id": "if-else",
|
|
|
|
|
"data": {
|
|
|
|
|
"title": "123",
|
|
|
|
|
"type": "if-else",
|
|
|
|
|
"logical_operator": "or",
|
|
|
|
|
"conditions": [
|
|
|
|
|
{
|
|
|
|
|
"comparison_operator": "contains",
|
|
|
|
|
"variable_selector": ["start", "array_contains"],
|
|
|
|
|
"value": "ab",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"comparison_operator": "not contains",
|
|
|
|
|
"variable_selector": ["start", "array_not_contains"],
|
|
|
|
|
"value": "ab",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
node = IfElseNode(
|
|
|
|
|
id=str(uuid.uuid4()),
|
|
|
|
|
graph_init_params=init_params,
|
|
|
|
|
graph=graph,
|
|
|
|
|
graph_runtime_state=GraphRuntimeState(variable_pool=pool, start_at=time.perf_counter()),
|
|
|
|
|
config={
|
|
|
|
|
"id": "if-else",
|
|
|
|
|
"data": {
|
|
|
|
|
"title": "123",
|
|
|
|
|
"type": "if-else",
|
|
|
|
|
"logical_operator": "or",
|
|
|
|
|
"conditions": [
|
|
|
|
|
{
|
|
|
|
|
"comparison_operator": "contains",
|
|
|
|
|
"variable_selector": ["start", "array_contains"],
|
|
|
|
|
"value": "ab",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"comparison_operator": "not contains",
|
|
|
|
|
"variable_selector": ["start", "array_not_contains"],
|
|
|
|
|
"value": "ab",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
config=node_config,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Initialize node data
|
|
|
|
|
node.init_node_data(node_config["data"])
|
|
|
|
|
|
|
|
|
|
# Mock db.session.close()
|
|
|
|
|
db.session.close = MagicMock()
|
|
|
|
|
|
|
|
|
|
@ -228,17 +238,22 @@ def test_array_file_contains_file_name():
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
node_config = {
|
|
|
|
|
"id": "if-else",
|
|
|
|
|
"data": node_data.model_dump(),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
node = IfElseNode(
|
|
|
|
|
id=str(uuid.uuid4()),
|
|
|
|
|
graph_init_params=Mock(),
|
|
|
|
|
graph=Mock(),
|
|
|
|
|
graph_runtime_state=Mock(),
|
|
|
|
|
config={
|
|
|
|
|
"id": "if-else",
|
|
|
|
|
"data": node_data.model_dump(),
|
|
|
|
|
},
|
|
|
|
|
config=node_config,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Initialize node data
|
|
|
|
|
node.init_node_data(node_config["data"])
|
|
|
|
|
|
|
|
|
|
node.graph_runtime_state.variable_pool.get.return_value = ArrayFileSegment(
|
|
|
|
|
value=[
|
|
|
|
|
File(
|
|
|
|
|
|