diff --git a/easywebdav/client.py b/easywebdav/client.py index 4003198..9d6b9d6 100644 --- a/easywebdav/client.py +++ b/easywebdav/client.py @@ -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): @@ -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: diff --git a/tests/tests.py b/tests/tests.py index 173f9a6..2330902 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -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) \ No newline at end of file