feat/enhance the multi-modal support (#8818)

This commit is contained in:
-LAN-
2024-10-21 10:43:49 +08:00
committed by GitHub
parent 7a1d6fe509
commit e61752bd3a
267 changed files with 6263 additions and 3523 deletions

View File

@@ -5,13 +5,13 @@ from urllib.parse import urlencode
import pytest
from core.app.entities.app_invoke_entities import InvokeFrom
from core.workflow.entities.node_entities import UserFrom
from core.workflow.entities.variable_pool import VariablePool
from core.workflow.enums import SystemVariableKey
from core.workflow.graph_engine.entities.graph import Graph
from core.workflow.graph_engine.entities.graph_init_params import GraphInitParams
from core.workflow.graph_engine.entities.graph_runtime_state import GraphRuntimeState
from core.workflow.nodes.http_request.http_request_node import HttpRequestNode
from core.workflow.nodes.http_request.node import HttpRequestNode
from models.enums import UserFrom
from models.workflow import WorkflowType
from tests.integration_tests.workflow.nodes.__mock.http import setup_http_mock
@@ -211,7 +211,16 @@ def test_json(setup_http_mock):
},
"headers": "X-Header:123",
"params": "A:b",
"body": {"type": "json", "data": '{"a": "{{#a.b123.args1#}}"}'},
"body": {
"type": "json",
"data": [
{
"key": "",
"type": "text",
"value": '{"a": "{{#a.b123.args1#}}"}',
},
],
},
},
}
)
@@ -243,7 +252,21 @@ def test_x_www_form_urlencoded(setup_http_mock):
},
"headers": "X-Header:123",
"params": "A:b",
"body": {"type": "x-www-form-urlencoded", "data": "a:{{#a.b123.args1#}}\nb:{{#a.b123.args2#}}"},
"body": {
"type": "x-www-form-urlencoded",
"data": [
{
"key": "a",
"type": "text",
"value": "{{#a.b123.args1#}}",
},
{
"key": "b",
"type": "text",
"value": "{{#a.b123.args2#}}",
},
],
},
},
}
)
@@ -275,7 +298,21 @@ def test_form_data(setup_http_mock):
},
"headers": "X-Header:123",
"params": "A:b",
"body": {"type": "form-data", "data": "a:{{#a.b123.args1#}}\nb:{{#a.b123.args2#}}"},
"body": {
"type": "form-data",
"data": [
{
"key": "a",
"type": "text",
"value": "{{#a.b123.args1#}}",
},
{
"key": "b",
"type": "text",
"value": "{{#a.b123.args2#}}",
},
],
},
},
}
)
@@ -310,7 +347,7 @@ def test_none_data(setup_http_mock):
},
"headers": "X-Header:123",
"params": "A:b",
"body": {"type": "none", "data": "123123123"},
"body": {"type": "none", "data": []},
},
}
)
@@ -366,7 +403,21 @@ def test_multi_colons_parse(setup_http_mock):
},
"params": "Referer:http://example1.com\nRedirect:http://example2.com",
"headers": "Referer:http://example3.com\nRedirect:http://example4.com",
"body": {"type": "form-data", "data": "Referer:http://example5.com\nRedirect:http://example6.com"},
"body": {
"type": "form-data",
"data": [
{
"key": "Referer",
"type": "text",
"value": "http://example5.com",
},
{
"key": "Redirect",
"type": "text",
"value": "http://example6.com",
},
],
},
},
}
)
@@ -377,5 +428,5 @@ def test_multi_colons_parse(setup_http_mock):
resp = result.outputs
assert urlencode({"Redirect": "http://example2.com"}) in result.process_data.get("request", "")
assert 'form-data; name="Redirect"\n\nhttp://example6.com' in result.process_data.get("request", "")
assert "http://example3.com" == resp.get("headers", {}).get("referer")
assert 'form-data; name="Redirect"\r\n\r\nhttp://example6.com' in result.process_data.get("request", "")
# assert "http://example3.com" == resp.get("headers", {}).get("referer")