mirror of
https://github.com/langgenius/dify.git
synced 2026-05-09 21:28:25 +08:00
test(api): fix broken HITL tests
This commit is contained in:
parent
343982bd46
commit
c4b2985361
@ -31,7 +31,7 @@ def _upload_context() -> SimpleNamespace:
|
||||
return SimpleNamespace(
|
||||
form_id="form-1",
|
||||
upload_token_id="token-row-1",
|
||||
end_user=SimpleNamespace(id="end-user-1", tenant_id="tenant-1"),
|
||||
owner=SimpleNamespace(id="owner-1", current_tenant_id="tenant-1"),
|
||||
)
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ def test_local_upload_ignores_source_and_records_form_file_link(monkeypatch: pyt
|
||||
assert result["id"] == "file-1"
|
||||
file_service.upload_file.assert_called_once()
|
||||
assert file_service.upload_file.call_args.kwargs["source"] is None
|
||||
assert file_service.upload_file.call_args.kwargs["user"].id == "end-user-1"
|
||||
assert file_service.upload_file.call_args.kwargs["user"].id == "owner-1"
|
||||
service.record_upload_file.assert_called_once_with(
|
||||
context=service.validate_upload_token.return_value,
|
||||
file_id="file-1",
|
||||
@ -115,9 +115,7 @@ def test_local_upload_missing_file_raises_after_valid_token(monkeypatch: pytest.
|
||||
service.validate_upload_token.assert_called_once_with("hitl_upload_token-1")
|
||||
|
||||
|
||||
def test_remote_upload_validates_token_before_fetching_remote_url(
|
||||
monkeypatch: pytest.MonkeyPatch, app: Flask
|
||||
) -> None:
|
||||
def test_remote_upload_validates_token_before_fetching_remote_url(monkeypatch: pytest.MonkeyPatch, app: Flask) -> None:
|
||||
service = MagicMock()
|
||||
service.validate_upload_token.side_effect = InvalidUploadTokenForbiddenError()
|
||||
monkeypatch.setattr(upload_module, "HumanInputFileUploadService", lambda engine: service)
|
||||
@ -180,6 +178,7 @@ def test_remote_upload_records_form_file_link(monkeypatch: pytest.MonkeyPatch, a
|
||||
assert result["url"] == "signed:file-1"
|
||||
file_service.upload_file.assert_called_once()
|
||||
assert file_service.upload_file.call_args.kwargs["source_url"] == "https://example.com/file.txt"
|
||||
assert file_service.upload_file.call_args.kwargs["user"].id == "owner-1"
|
||||
service.record_upload_file.assert_called_once_with(
|
||||
context=service.validate_upload_token.return_value,
|
||||
file_id="file-1",
|
||||
|
||||
@ -51,7 +51,7 @@ from core.base.tts.app_generator_tts_publisher import AudioTrunk
|
||||
from core.workflow.system_variables import build_system_variables
|
||||
from graphon.entities.pause_reason import PauseReasonType
|
||||
from graphon.enums import BuiltinNodeTypes
|
||||
from graphon.nodes.human_input.entities import UserAction
|
||||
from graphon.nodes.human_input.entities import UserActionConfig
|
||||
from graphon.runtime import GraphRuntimeState, VariablePool
|
||||
from libs.datetime_utils import naive_utc_now
|
||||
from models.enums import MessageStatus
|
||||
@ -148,7 +148,7 @@ class TestAdvancedChatGenerateTaskPipeline:
|
||||
node_title="Approval",
|
||||
form_content="Need approval",
|
||||
inputs=[],
|
||||
actions=[UserAction(id="approve", title="Approve")],
|
||||
actions=[UserActionConfig(id="approve", title="Approve")],
|
||||
display_in_ui=True,
|
||||
form_token="token-1",
|
||||
resolved_default_values={},
|
||||
|
||||
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from datetime import UTC, datetime
|
||||
from types import SimpleNamespace
|
||||
|
||||
from graphon.nodes.human_input.entities import FormDefinition, FormInput, UserAction
|
||||
from graphon.nodes.human_input.entities import FormDefinition, ParagraphInputConfig, UserActionConfig
|
||||
from graphon.nodes.human_input.enums import FormInputType
|
||||
from models.human_input import RecipientType
|
||||
from repositories.sqlalchemy_api_workflow_run_repository import _build_human_input_required_reason
|
||||
@ -13,8 +13,8 @@ def _build_form_model() -> SimpleNamespace:
|
||||
expiration_time = datetime(2024, 1, 1, tzinfo=UTC)
|
||||
definition = FormDefinition(
|
||||
form_content="content",
|
||||
inputs=[FormInput(type=FormInputType.TEXT_INPUT, output_variable_name="name")],
|
||||
user_actions=[UserAction(id="approve", title="Approve")],
|
||||
inputs=[ParagraphInputConfig(type=FormInputType.PARAGRAPH, output_variable_name="name")],
|
||||
user_actions=[UserActionConfig(id="approve", title="Approve")],
|
||||
rendered_content="rendered",
|
||||
expiration_time=expiration_time,
|
||||
default_values={"name": "Alice"},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user