fix: restore additional=["size","time"] to list_dir, update SPEC + tests

Root cause of DSM 408 was wrong path format (volume path vs share path),
not the additional parameter. Confirmed via test_additional.py that
json.dumps(["size","time"]) is the correct format; comma-separated string
is silently ignored by DSM.

- list_dir: restore 4-column table (Name, Type, Size, Modified)
- list_dir: use additional=json.dumps(["size","time"]) (confirmed working)
- SPEC.md: document share path requirement, additional format rules,
  note SYNO.FileStation.Stat unavailability, remove comma-sep gotcha
- tests: restore size/mtime mock data and assertions
- delete test_additional.py (throwaway diagnostic script)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-14 09:21:52 +02:00
parent 4c093589c1
commit 8fc2f731ce
4 changed files with 74 additions and 150 deletions
+27 -6
View File
@@ -79,7 +79,7 @@ async def test_list_shares_success(config: AppConfig) -> None:
result = await tools["list_shares"]()
assert "data" in result
assert "/data" in result # share path, not volume path
assert "/data" in result # share path, not volume path
assert "/volume1/data" not in result
assert "photos" in result
assert "2 share(s) found" in result
@@ -121,15 +121,27 @@ async def test_list_shares_dsm_error(config: AppConfig) -> None:
@pytest.mark.asyncio
async def test_list_dir_success(config: AppConfig) -> None:
"""list_dir returns a formatted table with name and type columns."""
"""list_dir returns a formatted table with name, type, size, and modified columns."""
client = MagicMock()
client.request = AsyncMock(
return_value={
"total": 3,
"files": [
{"name": "documents", "isdir": True},
{"name": "photo.jpg", "isdir": False},
{"name": "readme.txt", "isdir": False},
{
"name": "documents",
"isdir": True,
"additional": {"size": 0, "time": {"mtime": 1700000000}},
},
{
"name": "photo.jpg",
"isdir": False,
"additional": {"size": 2_048_000, "time": {"mtime": 1710000000}},
},
{
"name": "readme.txt",
"isdir": False,
"additional": {"size": 512, "time": {"mtime": 1720000000}},
},
],
}
)
@@ -142,6 +154,11 @@ async def test_list_dir_success(config: AppConfig) -> None:
assert "readme.txt" in result
assert "dir" in result
assert "file" in result
# Size column: dirs show "-", files show human-readable size
assert "2 MB" in result or "1 MB" in result # photo.jpg ~2 MB
assert "512 B" in result # readme.txt
# Modified column present
assert "Modified" in result
assert "Showing 13 of 3 item(s)" in result
@@ -153,7 +170,11 @@ async def test_list_dir_pagination(config: AppConfig) -> None:
return_value={
"total": 200,
"files": [
{"name": f"file{i}.txt", "isdir": False}
{
"name": f"file{i}.txt",
"isdir": False,
"additional": {"size": 100, "time": {"mtime": 1700000000}},
}
for i in range(100)
],
}