mirror of
https://github.com/langgenius/dify.git
synced 2026-06-26 14:51:13 +08:00
[autofix.ci] apply automated fixes
This commit is contained in:
parent
c55629c84d
commit
f7478e0ea2
@ -140,18 +140,14 @@ def _build_download_mapping(
|
||||
) -> AgentStubFileMapping:
|
||||
if mapping is not None:
|
||||
if transfer_method is not None or reference_or_url is not None:
|
||||
raise AgentStubValidationError(
|
||||
"--mapping cannot be combined with TRANSFER_METHOD or REFERENCE_OR_URL"
|
||||
)
|
||||
raise AgentStubValidationError("--mapping cannot be combined with TRANSFER_METHOD or REFERENCE_OR_URL")
|
||||
try:
|
||||
return AgentStubFileMapping.model_validate_json(mapping)
|
||||
except ValidationError as exc:
|
||||
raise AgentStubValidationError("invalid file download mapping") from exc
|
||||
|
||||
if transfer_method is None or reference_or_url is None:
|
||||
raise AgentStubValidationError(
|
||||
"file download requires either --mapping or TRANSFER_METHOD REFERENCE_OR_URL"
|
||||
)
|
||||
raise AgentStubValidationError("file download requires either --mapping or TRANSFER_METHOD REFERENCE_OR_URL")
|
||||
|
||||
normalized_transfer_method = cast(
|
||||
Literal["local_file", "tool_file", "datasource_file", "remote_url"],
|
||||
|
||||
@ -62,6 +62,7 @@ class DifyDriveLayerError(RuntimeError):
|
||||
class DifyDriveDeps(LayerDeps):
|
||||
execution_context: Layer[Any, Any, Any, Any, Any, Any] # pyright: ignore[reportUninitializedInstanceVariable]
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class DifyDriveLayer(PlainLayer[DifyDriveDeps, DifyDriveLayerConfig, EmptyRuntimeState]):
|
||||
"""Drive runtime layer that eagerly materializes prompt-mentioned drive targets."""
|
||||
|
||||
@ -90,9 +90,7 @@ def test_format_drive_manifest_returns_human_readable_listing(monkeypatch: pytes
|
||||
fake_manifest,
|
||||
)
|
||||
|
||||
result = format_drive_manifest(
|
||||
list_drive_manifest_from_environment(prefix="skills/")
|
||||
)
|
||||
result = format_drive_manifest(list_drive_manifest_from_environment(prefix="skills/"))
|
||||
|
||||
assert result == ("12\ttext/markdown\t-\tskills/example/SKILL.md\n-\t-\tsha256:abc\tskills/example/helper.py")
|
||||
assert captured["prefix"] == "skills/"
|
||||
@ -529,9 +527,7 @@ def test_pull_drive_from_environment_returns_json_result(
|
||||
result = pull_drive_from_environment(targets=["files/a.txt"], local_base=str(tmp_path))
|
||||
|
||||
assert isinstance(result, DrivePullResult)
|
||||
assert result.model_dump() == {
|
||||
"items": [{"key": "files/a.txt", "local_path": str(tmp_path / "files" / "a.txt")}]
|
||||
}
|
||||
assert result.model_dump() == {"items": [{"key": "files/a.txt", "local_path": str(tmp_path / "files" / "a.txt")}]}
|
||||
assert (tmp_path / "files" / "a.txt").read_bytes() == b"a"
|
||||
|
||||
|
||||
|
||||
@ -212,7 +212,9 @@ def test_cli_file_download_supports_mapping_json(
|
||||
captured_kwargs.update(kwargs)
|
||||
return type("Response", (), {"path": Path("/tmp/inputs/report.pdf")})()
|
||||
|
||||
monkeypatch.setattr("dify_agent.agent_stub.cli.main.download_file_from_environment", fake_download_file_from_environment)
|
||||
monkeypatch.setattr(
|
||||
"dify_agent.agent_stub.cli.main.download_file_from_environment", fake_download_file_from_environment
|
||||
)
|
||||
|
||||
with pytest.raises(SystemExit) as exc_info:
|
||||
main(
|
||||
@ -248,7 +250,9 @@ def test_cli_file_download_rejects_legacy_positional_directory(
|
||||
called = True
|
||||
return type("Response", (), {"path": Path("/tmp/report.pdf")})()
|
||||
|
||||
monkeypatch.setattr("dify_agent.agent_stub.cli.main.download_file_from_environment", fake_download_file_from_environment)
|
||||
monkeypatch.setattr(
|
||||
"dify_agent.agent_stub.cli.main.download_file_from_environment", fake_download_file_from_environment
|
||||
)
|
||||
|
||||
with pytest.raises(SystemExit) as exc_info:
|
||||
main(["file", "download", "tool_file", _reference("tool-file-1"), "/tmp"])
|
||||
@ -323,8 +327,12 @@ def test_cli_drive_pull_prints_downloaded_paths(
|
||||
"dify_agent.agent_stub.cli.main.pull_drive_from_environment",
|
||||
lambda *, targets, local_base: DrivePullResult(
|
||||
items=[
|
||||
DrivePullResult.Item(key=f"{targets[0]}/SKILL.md", local_path=str(Path(local_base) / targets[0] / "SKILL.md")),
|
||||
DrivePullResult.Item(key=f"{targets[0]}/helper.py", local_path=str(Path(local_base) / targets[0] / "helper.py")),
|
||||
DrivePullResult.Item(
|
||||
key=f"{targets[0]}/SKILL.md", local_path=str(Path(local_base) / targets[0] / "SKILL.md")
|
||||
),
|
||||
DrivePullResult.Item(
|
||||
key=f"{targets[0]}/helper.py", local_path=str(Path(local_base) / targets[0] / "helper.py")
|
||||
),
|
||||
]
|
||||
),
|
||||
)
|
||||
@ -377,7 +385,11 @@ def test_cli_drive_pull_forwards_multiple_targets(
|
||||
captured_kwargs["targets"] = targets
|
||||
captured_kwargs["local_base"] = local_base
|
||||
return DrivePullResult(
|
||||
items=[DrivePullResult.Item(key="skills/foo/SKILL.md", local_path=str(Path(local_base) / "skills" / "foo" / "SKILL.md"))]
|
||||
items=[
|
||||
DrivePullResult.Item(
|
||||
key="skills/foo/SKILL.md", local_path=str(Path(local_base) / "skills" / "foo" / "SKILL.md")
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
monkeypatch.setattr(
|
||||
@ -405,7 +417,11 @@ def test_cli_drive_pull_uses_environment_drive_base_default(
|
||||
captured_kwargs["targets"] = targets
|
||||
captured_kwargs["local_base"] = local_base
|
||||
return DrivePullResult(
|
||||
items=[DrivePullResult.Item(key="skills/foo/SKILL.md", local_path=str(Path(local_base) / "skills" / "foo" / "SKILL.md"))]
|
||||
items=[
|
||||
DrivePullResult.Item(
|
||||
key="skills/foo/SKILL.md", local_path=str(Path(local_base) / "skills" / "foo" / "SKILL.md")
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
monkeypatch.setattr(
|
||||
@ -433,7 +449,11 @@ def test_cli_drive_pull_keeps_historical_drive_base_when_env_is_missing(
|
||||
captured_kwargs["targets"] = targets
|
||||
captured_kwargs["local_base"] = local_base
|
||||
return DrivePullResult(
|
||||
items=[DrivePullResult.Item(key="skills/foo/SKILL.md", local_path=str(Path(local_base) / "skills" / "foo" / "SKILL.md"))]
|
||||
items=[
|
||||
DrivePullResult.Item(
|
||||
key="skills/foo/SKILL.md", local_path=str(Path(local_base) / "skills" / "foo" / "SKILL.md")
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
monkeypatch.setattr(
|
||||
@ -459,7 +479,9 @@ def test_cli_drive_pull_without_targets_pulls_whole_visible_drive(
|
||||
def fake_pull_drive_from_environment(*, targets, local_base):
|
||||
captured_kwargs["targets"] = targets
|
||||
captured_kwargs["local_base"] = local_base
|
||||
return DrivePullResult(items=[DrivePullResult.Item(key="files/a.txt", local_path=str(Path(local_base) / "files" / "a.txt"))])
|
||||
return DrivePullResult(
|
||||
items=[DrivePullResult.Item(key="files/a.txt", local_path=str(Path(local_base) / "files" / "a.txt"))]
|
||||
)
|
||||
|
||||
monkeypatch.setattr(
|
||||
"dify_agent.agent_stub.cli.main.pull_drive_from_environment",
|
||||
|
||||
@ -309,7 +309,9 @@ async def test_download_items_hands_validated_downloads_to_materialization(
|
||||
)
|
||||
captured: dict[str, object] = {}
|
||||
|
||||
def fake_materialize_drive_downloads(*, base_path: Path, downloads: list[DriveDownloadPayload], archive_skip_entry_names_by_dir):
|
||||
def fake_materialize_drive_downloads(
|
||||
*, base_path: Path, downloads: list[DriveDownloadPayload], archive_skip_entry_names_by_dir
|
||||
):
|
||||
captured["base_path"] = base_path
|
||||
captured["downloads"] = downloads
|
||||
captured["archive_skip_entry_names_by_dir"] = archive_skip_entry_names_by_dir
|
||||
|
||||
Loading…
Reference in New Issue
Block a user