Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions easywebdav/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class OperationFailed(WebdavException):
DELETE = "delete",
MKCOL = "create directory",
PROPFIND = "list directory",
MOVE = "move file",
)

def __init__(self, method, path, expected_code, actual_code):
Expand Down Expand Up @@ -149,6 +150,9 @@ def rmdir(self, path, safe=False):
def delete(self, path):
self._send('DELETE', path, 204)

def move(self, path, new_path):
self._send('MOVE', path, 204,headers={"Destination":new_path,'Connection':'TE','TE':'trailers','Overwrite':'T'})

def upload(self, local_path_or_fileobj, remote_path):
if isinstance(local_path_or_fileobj, basestring):
with open(local_path_or_fileobj, 'rb') as f:
Expand Down
20 changes: 20 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,23 @@ def test__upload_stream(self):
sio.seek(0)
self.client.upload(sio, 'file')
self._assert_file('file', self.content)


def test__move(self):
path = self._local_file(self.content)
self.client.upload(path, 'file')
self.client.move(path, 'file', 'filemove')
self._assert_file('filemove', self.content)
def test__move_nested(self):
path = self._local_file(self.content)
self._create_dir('one')
self.client.upload(path, 'one/file')
self.client.move(path, 'one/file', 'one/filemove')
self._assert_file('one/filemove', self.content)
def test__move_nested_absolute(self):
path = self._local_file(self.content)
self._create_dir('one', 'two')
self.client.cd('one')
self.client.upload(path, '/two/file')
self.client.move(path, '/two/file', '/two/filemove')
self._assert_file('two/filemove', self.content)