Merge pull request #466 from Unrud/fixpath

Set correct path for child collections
This commit is contained in:
Guillaume Ayoub 2016-08-07 18:43:41 +02:00 committed by GitHub
commit 9f2cbb81a3
3 changed files with 20 additions and 2 deletions

View File

@ -497,8 +497,9 @@ class Collection(BaseCollection):
continue
child_filesystem_path = path_to_filesystem(filesystem_path, href)
if os.path.isdir(child_filesystem_path):
child_path = posixpath.join(path, href)
child_principal = len(attributes) == 0
yield cls(child_filesystem_path, child_principal)
yield cls(child_path, child_principal)
@classmethod
def create_collection(cls, href, collection=None, props=None):

View File

@ -20,6 +20,7 @@ Radicale tests with simple requests.
"""
import logging
import posixpath
import shutil
import tempfile
@ -188,6 +189,21 @@ class BaseRequests:
status, headers, answer = self.request("GET", "/event1.ics")
assert status == 404
def test_propfind(self):
calendar_path = "/calendar.ics/"
self.request("MKCALENDAR", calendar_path)
event = get_file_content("event1.ics")
event_path = posixpath.join(calendar_path, "event.ics")
self.request("PUT", event_path, event)
status, headers, answer = self.request("PROPFIND", "/", HTTP_DEPTH="1")
assert status == 207
assert "href>/</" in answer
assert "href>%s</" % calendar_path in answer
status, headers, answer = self.request("PROPFIND", calendar_path, HTTP_DEPTH="1")
assert status == 207
assert "href>%s</" % calendar_path in answer
assert "href>%s</" % event_path in answer
def test_multiple_events_with_same_uid(self):
"""Add two events with the same UID."""
self.request("MKCOL", "/calendar.ics/")

View File

@ -541,7 +541,8 @@ def _propfind_response(path, item, props, user, write=False):
href = ET.Element(_tag("D", "href"))
if is_collection:
uri = item.path
# Some clients expect collections to end with /
uri = item.path + "/"
else:
# TODO: fix this
if path.split("/")[-1] == item.href: