test(webdav): direct _webdav_path test + double-encode precondition (#891 r2)

Round-2 review on PR #891 (non-blocking):
- Add a parametrised test_webdav_path_encoding covering empty path,
  leading-slash stripping, '#'/comma/space, and a non-ASCII name — the single
  source of truth for every caller-path builder's encoding, so write_file /
  delete_resource / create_directory / attachments are covered transitively.
- Document the decoded-input precondition on _webdav_path (encode-exactly-once;
  passing an already-encoded path would double-encode).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-06-11 06:13:55 +02:00
co-authored by Claude Opus 4.8
parent a188e9fced
commit 7b274cd8e2
2 changed files with 28 additions and 0 deletions
+5
View File
@@ -54,6 +54,11 @@ class WebDAVClient(BaseNextcloudClient):
Percent-encodes the caller-supplied portion (see ``_encode_dav_path``)
so names with ``#``, commas, or spaces don't truncate/404; the base
``/remote.php/dav/files/<user>`` segment is left as-is.
Precondition: ``path`` is a **decoded** path (the convention everywhere
in this client — PROPFIND/REPORT hrefs are ``unquote``d before storage,
and MCP-tool inputs are raw). It is encoded exactly once, so passing an
already-encoded path would double-encode it (``%20`` → ``%2520``).
"""
return f"{self._get_webdav_base_path()}/{_encode_dav_path(path.lstrip('/'))}"