mirror of
https://github.com/TencentCloud/Octop.git
synced 2026-10-21 06:29:24 +08:00
* fix: adapt S3/Postgres backends and restore admin storage browse Published octop-harness 1.0.1 plus Octop-side spec mapping and protocol wrap stop expert start and Admin tree listing from failing on the older deepagents_backends surface. Browse now caches the backend session and can preview or download files. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: keep Windows paths valid in storage browse fixtures f-string JSON turns backslashes into illegal escapes, so row_to_backend_spec sees an incomplete filesystem config on Windows CI. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: write browse fixture bytes without Windows newline translation Path.write_text() converts LF to CRLF on Windows, so download assertions saw b'# hello\r\n'. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: jubaoliang <jubaoliang@tencent.com> Co-authored-by: Cursor <cursoragent@cursor.com>
59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
"""Tree listing entries stay anchored at the directory the caller requested."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from octop.api.common.workspace import reanchor_entry_path
|
|
|
|
|
|
def test_root_listing_entry_keeps_basename_only() -> None:
|
|
# Backend leaked a virtual key (root_dir above the workspace).
|
|
assert reanchor_entry_path(".octop/agents/MSPHTQ/agents/", parent=".") == "agents"
|
|
|
|
|
|
def test_subdir_listing_entry_is_prefixed_with_requested_dir() -> None:
|
|
assert (
|
|
reanchor_entry_path(".octop/agents/MSPHTQ/agents/general.md", parent="agents")
|
|
== "agents/general.md"
|
|
)
|
|
|
|
|
|
def test_workspace_relative_entry_is_unchanged() -> None:
|
|
assert reanchor_entry_path("skills/demo", parent="skills") == "skills/demo"
|
|
assert reanchor_entry_path("notes.md", parent=".") == "notes.md"
|
|
|
|
|
|
def test_empty_entry_path_is_dropped_to_parent() -> None:
|
|
assert reanchor_entry_path("", parent="skills") == "skills"
|
|
|
|
|
|
def test_dedupe_tree_rows_drops_parent_and_duplicate_dir_marker() -> None:
|
|
from octop.infra.backend.tree_listing import dedupe_tree_rows
|
|
|
|
rows = dedupe_tree_rows(
|
|
[
|
|
{"path": "/.octop", "is_dir": True},
|
|
{"path": "/.octop/", "is_dir": False, "size": 0},
|
|
{"path": "/.octop", "is_dir": True},
|
|
{"path": "/", "is_dir": True},
|
|
{"path": ".", "is_dir": True},
|
|
{"path": "/SOUL.md", "is_dir": False, "size": 12},
|
|
],
|
|
parent="/",
|
|
)
|
|
paths = [row["path"] for row in rows]
|
|
assert paths == ["/.octop", "/SOUL.md"]
|
|
assert rows[0]["is_dir"] is True
|
|
|
|
|
|
def test_dedupe_tree_rows_drops_self_when_listing_subdir() -> None:
|
|
from octop.infra.backend.tree_listing import dedupe_tree_rows
|
|
|
|
rows = dedupe_tree_rows(
|
|
[
|
|
{"path": "skills", "is_dir": True},
|
|
{"path": "skills/demo", "is_dir": True},
|
|
],
|
|
parent="skills",
|
|
)
|
|
assert [row["path"] for row in rows] == ["skills/demo"]
|