pre-release fixes
This commit is contained in:
parent
e80fe6c108
commit
8acce856e2
7 changed files with 8 additions and 1562 deletions
410
README.md
410
README.md
|
@ -1,410 +0,0 @@
|
|||
webdavclient
|
||||
============
|
||||
|
||||
[](http://badge.fury.io/py/webdavclient)
|
||||
[](https://requires.io/github/designerror/webdav-client-python/requirements/?branch=master&style=flat)
|
||||
[](https://www.pullreview.com/github/designerror/webdavclient/reviews/master)
|
||||
|
||||
Package webdavclient provides easy and convenient work with WebDAV-servers (Yandex.Drive, Dropbox, Google Drive, Box, 4shared, etc.). The package includes the following components: webdav API, resource API and wdc.
|
||||
|
||||
The source code of the project can be found
|
||||
[here](https://github.com/designerror/webdavclient)
|
||||

|
||||
|
||||
Installation and upgrade
|
||||
======================
|
||||
|
||||
**Installation**
|
||||
|
||||
> Linux
|
||||
|
||||
```bash
|
||||
$ sudo apt-get install libxml2-dev libxslt-dev python-dev
|
||||
$ sudo apt-get install libcurl4-openssl-dev python-pycurl
|
||||
$ sudo easy_install webdavclient
|
||||
```
|
||||
|
||||
> macOS
|
||||
|
||||
```bash
|
||||
$ curl https://bootstrap.pypa.io/ez_setup.py -o - | python
|
||||
$ python setup.py install --prefix=/opt/setuptools
|
||||
$ sudo easy_install webdavclient
|
||||
```
|
||||
|
||||
**Update**
|
||||
|
||||
```bash
|
||||
$ sudo pip install -U webdavclient
|
||||
```
|
||||
|
||||
Webdav API
|
||||
==========
|
||||
|
||||
Webdav API is a set of webdav methods of work with cloud storage. This set includes the following methods: `check`, `free`, `info`, `list`, `mkdir`, `clean`, `copy`, `move`, `download`, `upload`, `publish` and `unpublish`.
|
||||
|
||||
**Configuring the client**
|
||||
|
||||
Required keys for configuring client connection with WevDAV-server are webdav\_hostname and webdav\_login, webdav,\_password.
|
||||
|
||||
```python
|
||||
import webdav.client as wc
|
||||
options = {
|
||||
'webdav_hostname': "https://webdav.server.ru",
|
||||
'webdav_login': "login",
|
||||
'webdav_password': "password"
|
||||
}
|
||||
client = wc.Client(options)
|
||||
```
|
||||
|
||||
When a proxy server you need to specify settings to connect through it.
|
||||
|
||||
```python
|
||||
import webdav.client as wc
|
||||
options = {
|
||||
'webdav_hostname': "https://webdav.server.ru",
|
||||
'webdav_login': "w_login",
|
||||
'webdav_password': "w_password",
|
||||
'proxy_hostname': "http://127.0.0.1:8080",
|
||||
'proxy_login': "p_login",
|
||||
'proxy_password': "p_password"
|
||||
}
|
||||
client = wc.Client(options)
|
||||
```
|
||||
|
||||
If you want to use the certificate path to certificate and private key is defined as follows:
|
||||
|
||||
```python
|
||||
import webdav.client as wc
|
||||
options = {
|
||||
'webdav_hostname': "https://webdav.server.ru",
|
||||
'webdav_login': "w_login",
|
||||
'webdav_password': "w_password",
|
||||
'cert_path': "/etc/ssl/certs/certificate.crt",
|
||||
'key_path': "/etc/ssl/private/certificate.key"
|
||||
}
|
||||
client = wc.Client(options)
|
||||
```
|
||||
|
||||
Or you want to limit the speed or turn on verbose mode:
|
||||
|
||||
```python
|
||||
options = {
|
||||
...
|
||||
'recv_speed' : 3000000,
|
||||
'send_speed' : 3000000,
|
||||
'verbose' : True
|
||||
}
|
||||
client = wc.Client(options)
|
||||
```
|
||||
|
||||
recv_speed: rate limit data download speed in Bytes per second. Defaults to unlimited speed.
|
||||
send_speed: rate limit data upload speed in Bytes per second. Defaults to unlimited speed.
|
||||
verbose: set verbose mode on/off. By default verbose mode is off.
|
||||
|
||||
**Synchronous methods**
|
||||
|
||||
```python
|
||||
// Checking existence of the resource
|
||||
|
||||
client.check("dir1/file1")
|
||||
client.check("dir1")
|
||||
```
|
||||
|
||||
```python
|
||||
// Get information about the resource
|
||||
|
||||
client.info("dir1/file1")
|
||||
client.info("dir1/")
|
||||
```
|
||||
|
||||
```python
|
||||
// Check free space
|
||||
|
||||
free_size = client.free()
|
||||
```
|
||||
|
||||
```python
|
||||
// Get a list of resources
|
||||
|
||||
files1 = client.list()
|
||||
files2 = client.list("dir1")
|
||||
```
|
||||
|
||||
```python
|
||||
// Create directory
|
||||
|
||||
client.mkdir("dir1/dir2")
|
||||
```
|
||||
|
||||
```python
|
||||
// Delete resource
|
||||
|
||||
client.clean("dir1/dir2")
|
||||
```
|
||||
|
||||
```python
|
||||
// Copy resource
|
||||
|
||||
client.copy(remote_path_from="dir1/file1", remote_path_to="dir2/file1")
|
||||
client.copy(remote_path_from="dir2", remote_path_to="dir3")
|
||||
```
|
||||
|
||||
```python
|
||||
// Move resource
|
||||
|
||||
client.move(remote_path_from="dir1/file1", remote_path_to="dir2/file1")
|
||||
client.move(remote_path_from="dir2", remote_path_to="dir3")
|
||||
```
|
||||
|
||||
```python
|
||||
// Move resource
|
||||
|
||||
client.download_sync(remote_path="dir1/file1", local_path="~/Downloads/file1")
|
||||
client.download_sync(remote_path="dir1/dir2/", local_path="~/Downloads/dir2/")
|
||||
```
|
||||
|
||||
```python
|
||||
// Unload resource
|
||||
|
||||
client.upload_sync(remote_path="dir1/file1", local_path="~/Documents/file1")
|
||||
client.upload_sync(remote_path="dir1/dir2/", local_path="~/Documents/dir2/")
|
||||
```
|
||||
|
||||
```python
|
||||
// Publish the resource
|
||||
|
||||
link = client.publish("dir1/file1")
|
||||
link = client.publish("dir2")
|
||||
```
|
||||
|
||||
```python
|
||||
// Unpublish resource
|
||||
|
||||
client.unpublish("dir1/file1")
|
||||
client.unpublish("dir2")
|
||||
```
|
||||
|
||||
```python
|
||||
// Exception handling
|
||||
|
||||
from webdav.client import WebDavException
|
||||
try:
|
||||
...
|
||||
except WebDavException as exception:
|
||||
...
|
||||
```
|
||||
|
||||
```python
|
||||
// Get the missing files
|
||||
|
||||
client.pull(remote_directory='dir1', local_directory='~/Documents/dir1')
|
||||
```
|
||||
|
||||
```python
|
||||
// Send missing files
|
||||
|
||||
client.push(remote_directory='dir1', local_directory='~/Documents/dir1')
|
||||
```
|
||||
|
||||
**Asynchronous methods**
|
||||
|
||||
```python
|
||||
// Load resource
|
||||
|
||||
kwargs = {
|
||||
'remote_path': "dir1/file1",
|
||||
'local_path': "~/Downloads/file1",
|
||||
'callback': callback
|
||||
}
|
||||
client.download_async(**kwargs)
|
||||
|
||||
kwargs = {
|
||||
'remote_path': "dir1/dir2/",
|
||||
'local_path': "~/Downloads/dir2/",
|
||||
'callback': callback
|
||||
}
|
||||
client.download_async(**kwargs)
|
||||
```
|
||||
|
||||
```python
|
||||
// Unload resource
|
||||
|
||||
kwargs = {
|
||||
'remote_path': "dir1/file1",
|
||||
'local_path': "~/Downloads/file1",
|
||||
'callback': callback
|
||||
}
|
||||
client.upload_async(**kwargs)
|
||||
|
||||
kwargs = {
|
||||
'remote_path': "dir1/dir2/",
|
||||
'local_path': "~/Downloads/dir2/",
|
||||
'callback': callback
|
||||
}
|
||||
client.upload_async(**kwargs)
|
||||
```
|
||||
|
||||
Resource API
|
||||
============
|
||||
|
||||
Resource API using the concept of OOP that enables cloud-level resources.
|
||||
|
||||
```python
|
||||
// Get a resource
|
||||
|
||||
res1 = client.resource("dir1/file1")
|
||||
```
|
||||
|
||||
```python
|
||||
// Work with the resource
|
||||
|
||||
res1.rename("file2")
|
||||
res1.move("dir1/file2")
|
||||
res1.copy("dir2/file1")
|
||||
info = res1.info()
|
||||
res1.read_from(buffer)
|
||||
res1.read(local_path="~/Documents/file1")
|
||||
res1.read_async(local_path="~/Documents/file1", callback)
|
||||
res1.write_to(buffer)
|
||||
res1.write(local_path="~/Downloads/file1")
|
||||
res1.write_async(local_path="~/Downloads/file1", callback)
|
||||
```
|
||||
|
||||
wdc
|
||||
===
|
||||
|
||||
wdc - a cross-platform utility that provides convenient work with WebDAV-servers right from your console. In addition to full implementations of methods from webdav API, also added methods content sync local and remote directories.
|
||||
|
||||
**Authentication**
|
||||
|
||||
- *Basic authentication*
|
||||
```bash
|
||||
$ wdc login https://wedbav.server.ru -p http://127.0.0.1:8080
|
||||
webdav_login: w_login
|
||||
webdav_password: w_password
|
||||
proxy_login: p_login
|
||||
proxy_password: p_password
|
||||
success
|
||||
```
|
||||
|
||||
- Authorize the application using OAuth token*
|
||||
```bash
|
||||
$ wdc login https://wedbav.server.ru -p http://127.0.0.1:8080 --token xxxxxxxxxxxxxxxxxx
|
||||
proxy_login: p_login
|
||||
proxy_password: p_password
|
||||
success
|
||||
```
|
||||
|
||||
There are also additional keys `--root[-r]`, `--cert-path[-c]` and `--key-path[-k]`.
|
||||
|
||||
**Utility**
|
||||
|
||||
```bash
|
||||
$ wdc check
|
||||
success
|
||||
$ wdc check file1
|
||||
not success
|
||||
$ wdc free
|
||||
245234120344
|
||||
$ wdc ls dir1
|
||||
file1
|
||||
...
|
||||
fileN
|
||||
$ wdc mkdir dir2
|
||||
$ wdc copy dir1/file1 -t dir2/file1
|
||||
$ wdc move dir2/file1 -t dir2/file2
|
||||
$ wdc download dir1/file1 -t ~/Downloads/file1
|
||||
$ wdc download dir1/ -t ~/Downloads/dir1/
|
||||
$ wdc upload dir2/file2 -f ~/Documents/file1
|
||||
$ wdc upload dir2/ -f ~/Documents/
|
||||
$ wdc publish di2/file2
|
||||
https://yadi.sk/i/vWtTUcBucAc6k
|
||||
$ wdc unpublish dir2/file2
|
||||
$ wdc pull dir1/ -t ~/Documents/dir1/
|
||||
$ wdc push dir1/ -f ~/Documents/dir1/
|
||||
$ wdc info dir1/file1
|
||||
{'name': 'file1', 'modified': 'Thu, 23 Oct 2014 16:16:37 GMT',
|
||||
'size': '3460064', 'created': '2014-10-23T16:16:37Z'}
|
||||
```
|
||||
WebDAV-server
|
||||
=============
|
||||
|
||||
The most popular cloud-based repositories that support the Protocol WebDAV can be attributed Yandex.Drive, Dropbox, Google Drive, Box and 4shared. Access to data repositories, operating with access to the Internet. If necessary local locations and cloud storage, you can deploy your own WebDAV-server.
|
||||
|
||||
**Local WebDAV-server**
|
||||
|
||||
To deploy a local WebDAV server, using Docker containers
|
||||
quite easily and quickly. To see an example of a local deploymentWebDAV servers can be on the project [webdav-server-docker](https://github.com/designerror/webdav-server-docker).
|
||||
|
||||
**Supported methods**
|
||||
|
||||
Servers |free|info|list|mkdir|clean|copy|move|download|upload
|
||||
:------------|:--:|:--:|:--:|:---:|:---:|:--:|:--:|:------:|:----:
|
||||
Yandex.Disk| \+ | \+ | \+ | \+ | \+ | \+ | \+ | \+ | \+
|
||||
Dropbox| \- | \+ | \+ | \+ | \+ | \+ | \+ | \+ | \+
|
||||
Google Drive| \- | \+ | \+ | \+ | \+ | \- | \- | \+ | \+
|
||||
Box| \+ | \+ | \+ | \+ | \+ | \+ | \+ | \+ | \+
|
||||
4shared| \- | \+ | \+ | \+ | \+ | \- | \- | \+ | \+
|
||||
Webdavserver| \- | \+ | \+ | \+ | \+ | \- | \- | \+ | \+
|
||||
|
||||
Publish and unpublish methods supports only Yandex.Disk.
|
||||
|
||||
**Configuring connections**
|
||||
|
||||
To work with cloud storage Dropbox and Google Drive via the WebDAV Protocol, you must use a WebDAV-server DropDAV and DAV-pocket, respectively.
|
||||
|
||||
A list of settings for WebDAV servers:
|
||||
|
||||
```yaml
|
||||
webdav-servers:
|
||||
- yandex
|
||||
hostname: https://webdav.yandex.ru
|
||||
login: #login_for_yandex
|
||||
password: #pass_for_yandex
|
||||
- dropbox
|
||||
hostname: https://dav.dropdav.com
|
||||
login: #login_for dropdav
|
||||
password: #pass_for_dropdav
|
||||
- google
|
||||
hostname: https://dav-pocket.appspot.com
|
||||
root: docso
|
||||
login: #login_for_dav-pocket
|
||||
password: #pass_for_dav-pocket
|
||||
- box
|
||||
hostname: https://dav.box.com
|
||||
root: dav
|
||||
login: #login_for_box
|
||||
password: #pass_for_box
|
||||
- 4shared
|
||||
hostname: https://webdav.4shared.com
|
||||
login: #login_for_4shared
|
||||
password: #pass_for_4shared
|
||||
```
|
||||
|
||||
Autocompletion
|
||||
==============
|
||||
|
||||
For macOS, or older Unix systems you need to update bash.
|
||||
|
||||
```bash
|
||||
$ brew install bash
|
||||
$ chsh
|
||||
$ brew install bash-completion
|
||||
```
|
||||
|
||||
Autocompletion can be enabled globally
|
||||
|
||||
```bash
|
||||
$ sudo activate-global-python-argcomplete
|
||||
```
|
||||
|
||||
or locally
|
||||
|
||||
```bash
|
||||
#.bashrc
|
||||
eval "$(register-python-argcomplete wdc)"
|
||||
```
|
447
README.rst
447
README.rst
|
@ -1,446 +1,5 @@
|
|||
webdavclient
|
||||
webdavclient2
|
||||
============
|
||||
|
||||
|PyPI version| |Requirements Status| |PullReview stats|
|
||||
|
||||
Package webdavclient provides easy and convenient work with
|
||||
WebDAV-servers (Yandex.Drive, Dropbox, Google Drive, Box, 4shared,
|
||||
etc.). The package includes the following components: webdav API,
|
||||
resource API and wdc.
|
||||
|
||||
The source code of the project can be found
|
||||
`here <https://github.com/designerror/webdavclient>`__ |Github|
|
||||
|
||||
Installation and upgrade
|
||||
========================
|
||||
|
||||
**Installation**
|
||||
|
||||
- Linux
|
||||
|
||||
.. code:: bash
|
||||
|
||||
$ sudo apt-get install libxml2-dev libxslt-dev python-dev
|
||||
$ sudo apt-get install libcurl4-openssl-dev python-pycurl
|
||||
$ sudo easy_install webdavclient
|
||||
|
||||
- macOS
|
||||
|
||||
.. code:: bash
|
||||
|
||||
$ curl https://bootstrap.pypa.io/ez_setup.py -o - | python
|
||||
$ python setup.py install --prefix=/opt/setuptools
|
||||
$ sudo easy_install webdavclient
|
||||
|
||||
**Update**
|
||||
|
||||
.. code:: bash
|
||||
|
||||
$ sudo pip install -U webdavclient
|
||||
|
||||
Webdav API
|
||||
==========
|
||||
|
||||
Webdav API is a set of webdav methods of work with cloud storage. This
|
||||
set includes the following methods: ``check``, ``free``, ``info``,
|
||||
``list``, ``mkdir``, ``clean``, ``copy``, ``move``, ``download``,
|
||||
``upload``, ``publish`` and ``unpublish``.
|
||||
|
||||
**Configuring the client**
|
||||
|
||||
Required keys for configuring client connection with WevDAV-server are
|
||||
webdav\_hostname and webdav\_login, webdav,\_password.
|
||||
|
||||
.. code:: python
|
||||
|
||||
import webdav.client as wc
|
||||
options = {
|
||||
'webdav_hostname': "https://webdav.server.ru",
|
||||
'webdav_login': "login",
|
||||
'webdav_password': "password"
|
||||
}
|
||||
client = wc.Client(options)
|
||||
|
||||
When a proxy server you need to specify settings to connect through it.
|
||||
|
||||
.. code:: python
|
||||
|
||||
import webdav.client as wc
|
||||
options = {
|
||||
'webdav_hostname': "https://webdav.server.ru",
|
||||
'webdav_login': "w_login",
|
||||
'webdav_password': "w_password",
|
||||
'proxy_hostname': "http://127.0.0.1:8080",
|
||||
'proxy_login': "p_login",
|
||||
'proxy_password': "p_password"
|
||||
}
|
||||
client = wc.Client(options)
|
||||
|
||||
If you want to use the certificate path to certificate and private key
|
||||
is defined as follows:
|
||||
|
||||
.. code:: python
|
||||
|
||||
import webdav.client as wc
|
||||
options = {
|
||||
'webdav_hostname': "https://webdav.server.ru",
|
||||
'webdav_login': "w_login",
|
||||
'webdav_password': "w_password",
|
||||
'cert_path': "/etc/ssl/certs/certificate.crt",
|
||||
'key_path': "/etc/ssl/private/certificate.key"
|
||||
}
|
||||
client = wc.Client(options)
|
||||
|
||||
Or you want to limit the speed or turn on verbose mode:
|
||||
|
||||
.. code:: python
|
||||
|
||||
options = {
|
||||
...
|
||||
'recv_speed' : 3000000,
|
||||
'send_speed' : 3000000,
|
||||
'verbose' : True
|
||||
}
|
||||
client = wc.Client(options)
|
||||
|
||||
| recv\_speed: rate limit data download speed in Bytes per second.
|
||||
Defaults to unlimited speed.
|
||||
| send\_speed: rate limit data upload speed in Bytes per second.
|
||||
Defaults to unlimited speed.
|
||||
| verbose: set verbose mode on/off. By default verbose mode is off.
|
||||
|
||||
**Synchronous methods**
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Checking existence of the resource
|
||||
|
||||
client.check("dir1/file1")
|
||||
client.check("dir1")
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Get information about the resource
|
||||
|
||||
client.info("dir1/file1")
|
||||
client.info("dir1/")
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Check free space
|
||||
|
||||
free_size = client.free()
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Get a list of resources
|
||||
|
||||
files1 = client.list()
|
||||
files2 = client.list("dir1")
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Create directory
|
||||
|
||||
client.mkdir("dir1/dir2")
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Delete resource
|
||||
|
||||
client.clean("dir1/dir2")
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Copy resource
|
||||
|
||||
client.copy(remote_path_from="dir1/file1", remote_path_to="dir2/file1")
|
||||
client.copy(remote_path_from="dir2", remote_path_to="dir3")
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Move resource
|
||||
|
||||
client.move(remote_path_from="dir1/file1", remote_path_to="dir2/file1")
|
||||
client.move(remote_path_from="dir2", remote_path_to="dir3")
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Move resource
|
||||
|
||||
client.download_sync(remote_path="dir1/file1", local_path="~/Downloads/file1")
|
||||
client.download_sync(remote_path="dir1/dir2/", local_path="~/Downloads/dir2/")
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Unload resource
|
||||
|
||||
client.upload_sync(remote_path="dir1/file1", local_path="~/Documents/file1")
|
||||
client.upload_sync(remote_path="dir1/dir2/", local_path="~/Documents/dir2/")
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Publish the resource
|
||||
|
||||
link = client.publish("dir1/file1")
|
||||
link = client.publish("dir2")
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Unpublish resource
|
||||
|
||||
client.unpublish("dir1/file1")
|
||||
client.unpublish("dir2")
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Exception handling
|
||||
|
||||
from webdav.client import WebDavException
|
||||
try:
|
||||
...
|
||||
except WebDavException as exception:
|
||||
...
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Get the missing files
|
||||
|
||||
client.pull(remote_directory='dir1', local_directory='~/Documents/dir1')
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Send missing files
|
||||
|
||||
client.push(remote_directory='dir1', local_directory='~/Documents/dir1')
|
||||
|
||||
**Asynchronous methods**
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Load resource
|
||||
|
||||
kwargs = {
|
||||
'remote_path': "dir1/file1",
|
||||
'local_path': "~/Downloads/file1",
|
||||
'callback': callback
|
||||
}
|
||||
client.download_async(**kwargs)
|
||||
|
||||
kwargs = {
|
||||
'remote_path': "dir1/dir2/",
|
||||
'local_path': "~/Downloads/dir2/",
|
||||
'callback': callback
|
||||
}
|
||||
client.download_async(**kwargs)
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Unload resource
|
||||
|
||||
kwargs = {
|
||||
'remote_path': "dir1/file1",
|
||||
'local_path': "~/Downloads/file1",
|
||||
'callback': callback
|
||||
}
|
||||
client.upload_async(**kwargs)
|
||||
|
||||
kwargs = {
|
||||
'remote_path': "dir1/dir2/",
|
||||
'local_path': "~/Downloads/dir2/",
|
||||
'callback': callback
|
||||
}
|
||||
client.upload_async(**kwargs)
|
||||
|
||||
Resource API
|
||||
============
|
||||
|
||||
Resource API using the concept of OOP that enables cloud-level
|
||||
resources.
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Get a resource
|
||||
|
||||
res1 = client.resource("dir1/file1")
|
||||
|
||||
.. code:: python
|
||||
|
||||
// Work with the resource
|
||||
|
||||
res1.rename("file2")
|
||||
res1.move("dir1/file2")
|
||||
res1.copy("dir2/file1")
|
||||
info = res1.info()
|
||||
res1.read_from(buffer)
|
||||
res1.read(local_path="~/Documents/file1")
|
||||
res1.read_async(local_path="~/Documents/file1", callback)
|
||||
res1.write_to(buffer)
|
||||
res1.write(local_path="~/Downloads/file1")
|
||||
res1.write_async(local_path="~/Downloads/file1", callback)
|
||||
|
||||
wdc
|
||||
===
|
||||
|
||||
wdc \-a cross-platform utility that provides convenient work with
|
||||
WebDAV-servers right from your console. In addition to full
|
||||
implementations of methods from webdav API, also added methods content
|
||||
sync local and remote directories.
|
||||
|
||||
**Authentication**
|
||||
|
||||
- *Basic authentication*
|
||||
|
||||
.. code:: bash
|
||||
|
||||
$ wdc login https://wedbav.server.ru -p http://127.0.0.1:8080
|
||||
webdav_login: w_login
|
||||
webdav_password: w_password
|
||||
proxy_login: p_login
|
||||
proxy_password: p_password
|
||||
success
|
||||
|
||||
- Authorize the application using OAuth token\*
|
||||
|
||||
.. code:: bash
|
||||
|
||||
$ wdc login https://wedbav.server.ru -p http://127.0.0.1:8080 --token xxxxxxxxxxxxxxxxxx
|
||||
proxy_login: p_login
|
||||
proxy_password: p_password
|
||||
success
|
||||
|
||||
There are also additional keys ``--root[-r]``, ``--cert-path[-c]`` and
|
||||
``--key-path[-k]``.
|
||||
|
||||
**Utility**
|
||||
|
||||
.. code:: bash
|
||||
|
||||
$ wdc check
|
||||
success
|
||||
$ wdc check file1
|
||||
not success
|
||||
$ wdc free
|
||||
245234120344
|
||||
$ wdc ls dir1
|
||||
file1
|
||||
...
|
||||
fileN
|
||||
$ wdc mkdir dir2
|
||||
$ wdc copy dir1/file1 -t dir2/file1
|
||||
$ wdc move dir2/file1 -t dir2/file2
|
||||
$ wdc download dir1/file1 -t ~/Downloads/file1
|
||||
$ wdc download dir1/ -t ~/Downloads/dir1/
|
||||
$ wdc upload dir2/file2 -f ~/Documents/file1
|
||||
$ wdc upload dir2/ -f ~/Documents/
|
||||
$ wdc publish di2/file2
|
||||
https://yadi.sk/i/vWtTUcBucAc6k
|
||||
$ wdc unpublish dir2/file2
|
||||
$ wdc pull dir1/ -t ~/Documents/dir1/
|
||||
$ wdc push dir1/ -f ~/Documents/dir1/
|
||||
$ wdc info dir1/file1
|
||||
{'name': 'file1', 'modified': 'Thu, 23 Oct 2014 16:16:37 GMT',
|
||||
'size': '3460064', 'created': '2014-10-23T16:16:37Z'}
|
||||
|
||||
WebDAV-server
|
||||
=============
|
||||
|
||||
The most popular cloud-based repositories that support the Protocol
|
||||
WebDAV can be attributed Yandex.Drive, Dropbox, Google Drive, Box and
|
||||
4shared. Access to data repositories, operating with access to the
|
||||
Internet. If necessary local locations and cloud storage, you can deploy
|
||||
your own WebDAV-server.
|
||||
|
||||
**Local WebDAV-server**
|
||||
|
||||
To deploy a local WebDAV server, using Docker containers quite easily
|
||||
and quickly. To see an example of a local deploymentWebDAV servers can
|
||||
be on the project
|
||||
`webdav-server-docker <https://github.com/designerror/webdav-server-docker>`__.
|
||||
|
||||
**Supported methods**
|
||||
|
||||
+----------------+--------+--------+--------+---------+---------+--------+--------+------------+----------+
|
||||
| Servers | free | info | list | mkdir | clean | copy | move | download | upload |
|
||||
+================+========+========+========+=========+=========+========+========+============+==========+
|
||||
| Yandex.Disk | \+ | \+ | \+ | \+ | \+ | \+ | \+ | \+ | \+ |
|
||||
+----------------+--------+--------+--------+---------+---------+--------+--------+------------+----------+
|
||||
| Dropbox | \- | \+ | \+ | \+ | \+ | \+ | \+ | \+ | \+ |
|
||||
+----------------+--------+--------+--------+---------+---------+--------+--------+------------+----------+
|
||||
| Google Drive | \- | \+ | \+ | \+ | \+ | \- | \- | \+ | \+ |
|
||||
+----------------+--------+--------+--------+---------+---------+--------+--------+------------+----------+
|
||||
| Box | \+ | \+ | \+ | \+ | \+ | \+ | \+ | \+ | \+ |
|
||||
+----------------+--------+--------+--------+---------+---------+--------+--------+------------+----------+
|
||||
| 4shared | \- | \+ | \+ | \+ | \+ | \- | \- | \+ | \+ |
|
||||
+----------------+--------+--------+--------+---------+---------+--------+--------+------------+----------+
|
||||
| Webdavserver | \- | \+ | \+ | \+ | \+ | \- | \- | \+ | \+ |
|
||||
+----------------+--------+--------+--------+---------+---------+--------+--------+------------+----------+
|
||||
|
||||
Publish and unpublish methods supports only Yandex.Disk.
|
||||
|
||||
**Configuring connections**
|
||||
|
||||
To work with cloud storage Dropbox and Google Drive via the WebDAV
|
||||
Protocol, you must use a WebDAV-server DropDAV and DAV-pocket,
|
||||
respectively.
|
||||
|
||||
A list of settings for WebDAV servers:
|
||||
|
||||
.. code:: yaml
|
||||
|
||||
webdav-servers:
|
||||
- yandex
|
||||
hostname: https://webdav.yandex.ru
|
||||
login: #login_for_yandex
|
||||
password: #pass_for_yandex
|
||||
- dropbox
|
||||
hostname: https://dav.dropdav.com
|
||||
login: #login_for dropdav
|
||||
password: #pass_for_dropdav
|
||||
- google
|
||||
hostname: https://dav-pocket.appspot.com
|
||||
root: docso
|
||||
login: #login_for_dav-pocket
|
||||
password: #pass_for_dav-pocket
|
||||
- box
|
||||
hostname: https://dav.box.com
|
||||
root: dav
|
||||
login: #login_for_box
|
||||
password: #pass_for_box
|
||||
- 4shared
|
||||
hostname: https://webdav.4shared.com
|
||||
login: #login_for_4shared
|
||||
password: #pass_for_4shared
|
||||
|
||||
Autocompletion
|
||||
==============
|
||||
|
||||
For macOS, or older Unix systems you need to update bash.
|
||||
|
||||
.. code:: bash
|
||||
|
||||
$ brew install bash
|
||||
$ chsh
|
||||
$ brew install bash-completion
|
||||
|
||||
Autocompletion can be enabled globally
|
||||
|
||||
.. code:: bash
|
||||
|
||||
$ sudo activate-global-python-argcomplete
|
||||
|
||||
or locally
|
||||
|
||||
.. code:: bash
|
||||
|
||||
#.bashrc
|
||||
eval "$(register-python-argcomplete wdc)"
|
||||
|
||||
.. |PyPI version| image:: https://badge.fury.io/py/webdavclient.svg
|
||||
:target: http://badge.fury.io/py/webdavclient
|
||||
.. |Requirements Status| image:: https://requires.io/github/designerror/webdav-client-python/requirements.svg?branch=master&style=flat
|
||||
:target: https://requires.io/github/designerror/webdav-client-python/requirements/?branch=master&style=flat
|
||||
.. |PullReview stats| image:: https://www.pullreview.com/github/designerror/webdavclient/badges/master.svg?
|
||||
:target: https://www.pullreview.com/github/designerror/webdavclient/reviews/master
|
||||
.. |Github| image:: https://github.com/favicon.ico
|
||||
|
||||
Based on https://github.com/designerror/webdav-client-python
|
||||
But uses `requests` instead of `PyCURL`
|
688
TESTING.md
688
TESTING.md
|
@ -1,688 +0,0 @@
|
|||
Тестирование
|
||||
===
|
||||
|
||||
В пакет Webdavclient включены следующие компоненты:
|
||||
|
||||
- `webdav API`
|
||||
- `resource API`
|
||||
- `wdc`
|
||||
|
||||
Каждый из компонентов имеет свою <span style="text-decoration: underline">тестовую базу</span>.
|
||||
|
||||
### webdav API ###
|
||||
|
||||
Компонент webdav API содержит следующие <span style="text-decoration: underline">тестовые наборы</span>:
|
||||
|
||||
- настройка подключения
|
||||
- аутентификация
|
||||
- методы
|
||||
- интеграционные тесты
|
||||
|
||||
#### Настройка подключения ####
|
||||
|
||||
Для инициализации клиента используется словарь (настройки подключения), содержащий набор опций подключения к webdav-серверу.
|
||||
|
||||
Настройки подключения имеют обязательные и не обязательные опции. К обязательным опциям относятся `webdav_hostname`, `webdav_login` и `webdav_password`.
|
||||
|
||||
Заполнение полей может быть валидным или не валидным.
|
||||
Для проверки используются метод `valid?`.
|
||||
|
||||
```python
|
||||
import webdav.client as wc
|
||||
options = {
|
||||
'webdav_hostname': "https://webdav.server.ru",
|
||||
'webdav_login': "login",
|
||||
'webdav_password': "password"
|
||||
}
|
||||
client = wc.Client(options)
|
||||
client.valid?
|
||||
```
|
||||
|
||||
*Тестовый сценарий 1*
|
||||
|
||||
Идентификатор: 1.1.1
|
||||
Название: Обязательные опции подключения
|
||||
Описание: В случае присутствия каждой из обязательных опций,
|
||||
настройки подключения клиента будут валидными.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(client, is_(not_valid())
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
assert_that(client, is_(valid())
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 2*
|
||||
|
||||
Идентификатор: 1.1.2
|
||||
Название: Валидность обязательных опций подключения
|
||||
Описание: В случае валидности обязательных опций,
|
||||
настройки подключения клиента будут валидными.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
#without webdav_hostname
|
||||
#without webdav_login
|
||||
#without webdav_password
|
||||
#with proxy_login or proxy_password, but without proxy_hostname
|
||||
#with proxy_password and proxy_hostname, but without proxy_login
|
||||
assert_that(client, is_(not_valid())
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
assert_that(client, is_(valid())
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 3*
|
||||
|
||||
Идентификатор: 1.1.3
|
||||
Название: Валидность сертификата
|
||||
Описание: При указании валидного файла и ключа сертификата,
|
||||
настройки подключения клиента будут валидными.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
#with key_path, but without cert_path
|
||||
#key_path or cert_path not exists
|
||||
assert_that(calling(client.is_valid), raises(CertificateNotValid))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
assert_that(calling(client.is_valid), is_not(raises(CertificateNotValid))
|
||||
```
|
||||
|
||||
#### Аутентификация ####
|
||||
|
||||
При подключении к webdav-серверу, необходимо пройти у него basic-аутентификацию, для этого используются опции `webdav_login` и `webdav_password`. При наличии proxy-сервера, может потребоваться так же пройти аутентификацию и у proxy-сервера. Для proxy-сервера поддерживаются следующие виды аутентификации:
|
||||
|
||||
- `basic`
|
||||
- `digest`
|
||||
- `ntlm`
|
||||
- `negotiate`
|
||||
|
||||
|
||||
*Тестовый сценарий 1*
|
||||
|
||||
Идентификатор: 1.2.1
|
||||
Название: Аутентификация с webdav-сервером
|
||||
Описание: При правильной аутентификации клиент подключается к webdav-серверу.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.check), is_(not_suceess())
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
assert_that(calling(client.check), is_(suceess())
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 2*
|
||||
|
||||
Идентификатор: 1.2.2
|
||||
Название: Аутентификация с proxy-сервером
|
||||
Описание: При правильной аутентификации клиент подключается к webdav-серверу.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.check), is_(not_suceess())
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
#basic
|
||||
#digest
|
||||
#ntlm
|
||||
#negotiate
|
||||
assert_that(calling(client.check), is_(suceess())
|
||||
```
|
||||
|
||||
#### Методы ####
|
||||
|
||||
webdav API реализует следущие методы: `check`, `free`, `info`, `list`, `mkdir`, `clean`, `copy`, `move`, `download`, `upload`, `publish` и `unpublish`.
|
||||
|
||||
|
||||
*Тестовый сценарий 1*
|
||||
|
||||
Идентификатор: 1.3.1
|
||||
Название: Проверка существования ресурса
|
||||
Описание: В случае существования ресурса, результат выполнения метода check
|
||||
будет успешным.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.check).with_args(remote_path), is_(not_suceess())
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
assert_that(calling(client.check).with_args(remote_path), is_(suceess())
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 2*
|
||||
|
||||
Идентификатор: 1.3.2
|
||||
Название: Проверка свободного места
|
||||
Описание: В случае если webdav-сервер поддерживает метод free, метод возвращает
|
||||
размер свободного места.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.free), raises(MethodNotSupported))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
assert_that(calling(client.free), greater_than(0))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 3*
|
||||
|
||||
Идентификатор: 1.3.3
|
||||
Название: Получение информации о ресурсе
|
||||
Описание: В случае если webdav-сервер поддерживает метод info,
|
||||
метод возвращает информацию следующего типа:
|
||||
- дата создания;
|
||||
- дата модификации;
|
||||
- размер;
|
||||
- имя.
|
||||
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.info).with_args(remote_path), raises(RemoteResourceNotFound))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
info = client(remote_path)
|
||||
assert_that(info, has_key("data1"))
|
||||
assert_that(info, has_key("data2"))
|
||||
assert_that(info, has_key("size"))
|
||||
assert_that(info, has_key("name"))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 4*
|
||||
|
||||
Идентификатор: 1.3.4
|
||||
Название: Получение списка ресурсов
|
||||
Описание: В случае, если указанный ресурс существует и является директорией, то метод list
|
||||
возвращает список ресурсов, находящихся в данном ресурсе.
|
||||
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.info).with_args(remote_file), raises(RemoteResourceNotFound))
|
||||
assert_that(calling(client.list).with_args(remote_path), raises(RemoteResourceNotFound))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
files = client.list(remote_path)
|
||||
assert_that(files, not_none()))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 5*
|
||||
|
||||
Идентификатор: 1.3.5
|
||||
Название: Создание директории
|
||||
Описание: В случае, если все директории из путевого разбиения для
|
||||
указанного ресурса существуют, то данный ресурс будет создан.
|
||||
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.info).with_args(remote_path), raises(RemoteParentNotFound))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
client.mkdir(remote_path)
|
||||
assert_that(calling(client.check).with_args(remote_path), is_(success()))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 6*
|
||||
|
||||
Идентификатор: 1.3.6
|
||||
Название: Удаление ресурса
|
||||
Описание: В случае, если указанный ресурс существует и не является корнем, то
|
||||
метод clean удалит данный ресурс.
|
||||
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.clean).with_args(remote_path), raises(RemoteResourceNotFound))
|
||||
assert_that(calling(client.clean).with_args(root), raises(InvalidOption))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
client.clean(remote_path)
|
||||
assert_that(calling(client.check).with_args(remote_path), is_(not_success()))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 7*
|
||||
|
||||
Идентификатор: 1.3.7
|
||||
Название: Копирование ресурса
|
||||
Описание: В случае, если указанный ресурс существует и не является корнем, то
|
||||
метод copy копирует данный ресурс.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.copy).with_args(from_path=remote_path, to_path=new_path), raises(RemoteResourceNotFound))
|
||||
assert_that(calling(client.copy).with_args(from_path=root, to_path=new_path), raises(InvalidOption))
|
||||
assert_that(calling(client.copy).with_args(from_path=remote_path, to_path=root), raises(InvalidOption))
|
||||
assert_that(calling(client.copy).with_args(from_path=remote_path, to_path=remote_path), is_not(raises(WebDavException)))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
client.copy(from_path=remote_path, to_path=new_path)
|
||||
assert_that(calling(client.check).with_args(new_path), is_(success()))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 8*
|
||||
|
||||
Идентификатор: 1.3.8
|
||||
Название: Перемещение ресурса
|
||||
Описание: В случае, если указанный ресурс существует и не является корнем, то
|
||||
метод move переместит данный ресурс.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.move).with_args(from_path=old_path, to_path=new_path), raises(RemoteResourceNotFound))
|
||||
assert_that(calling(client.move).with_args(from_path=root, to_path=new_path), raises(InvalidOption))
|
||||
assert_that(calling(client.move).with_args(from_path=old_path, to_path=root), raises(InvalidOption))
|
||||
assert_that(calling(client.move).with_args(from_path=old_path, to_path=remote_path), is_not(raises(WebDavException)))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
client.move(from_path=old_path, to_path=new_path)
|
||||
assert_that(calling(client.check).with_args(old_path), is_(not_success()))
|
||||
assert_that(calling(client.check).with_args(new_path), is_(success()))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 9*
|
||||
|
||||
Идентификатор: 1.3.9
|
||||
Название: Загрузка ресурса
|
||||
Описание: В случае, если указанный ресурс существует,
|
||||
то метод download загрузит данный ресурс.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.download).with_args(remote_path=remote_path, local_path=local_path), raises(LocalResourceNotFound))
|
||||
assert_that(calling(client.download).with_args(remote_path=remote_path, local_path=local_path), raises(RemoteResourceNotFound))
|
||||
assert_that(calling(client.download).with_args(remote_path=remote_file, local_path=local_directory), raises(InvalidOption))
|
||||
assert_that(calling(client.download).with_args(remote_path=remote_directory, local_path=local_file), raises(InvalidOption))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
client.download(remote_path=remote_path, local_path=local_path)
|
||||
assert_that(local_path, is_(exist()))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 10*
|
||||
|
||||
Идентификатор: 1.3.10
|
||||
Название: Выгрузка ресурса
|
||||
Описание: В случае, если родительская директория указанный ресурса
|
||||
существует, то метод upload выгрузит файл или директорию в
|
||||
ресурс.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.upload).with_args(remote_path=remote_path, local_path=local_path), raises(RemoteParentNotFound))
|
||||
assert_that(calling(client.upload).with_args(remote_path=remote_file, local_path=local_directory), raises(InvalidOption))
|
||||
assert_that(calling(client.upload).with_args(remote_path=remote_directory, local_path=local_file), raises(InvalidOption))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
client.upload(remote_path=remote_path, to_path=local_path)
|
||||
assert_that(calling(client.check).with_args(remote_path), is_(success()))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 11*
|
||||
|
||||
Идентификатор: 1.3.11
|
||||
Название: Публикация ресурса
|
||||
Описание: В случае, если указанный ресурс существует, то метод publish
|
||||
возвращает публичную ссылку на ресурс.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.publish).with_args(remote_path), raises(RemoteResourceNotFound))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
assert_that(calling(client.publish).with_args(remote_path), is_not(raises(RemoteResourceNotFound))
|
||||
link = client.publish(remote_path)
|
||||
assert_that(link, starts_with("http")
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 12*
|
||||
|
||||
Идентификатор: 1.3.12
|
||||
Название: Отмена публикации ресурса
|
||||
Описание: В случае, если указанный ресурс существует,
|
||||
то метод unpublish отменяет публикацию ресурса.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.unpublish).with_args(remote_path), raises(RemoteResourceNotFound))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
assert_that(calling(client.unpublish).with_args(remote_path), is_not(raises(RemoteResourceNotFound))
|
||||
```
|
||||
|
||||
### resource API ###
|
||||
|
||||
Компонент resource API состоит из следующих <span style="text-decoration: underline">тестовых наборов</span> методы:
|
||||
|
||||
- получение ресурса
|
||||
- методы
|
||||
|
||||
#### Получение ресурса ####
|
||||
|
||||
Для получение ресурса, используется метод `resource`.
|
||||
|
||||
|
||||
*Тестовый сценарий 1*
|
||||
|
||||
Идентификатор: 2.1.1
|
||||
Название: Получение ресурса
|
||||
Описание: В случае, если указанный ресурс является директорией и существует,
|
||||
то метод resource возвращает ресурс.
|
||||
В случае, если указанный ресурс является файлом,
|
||||
то метод resource возвращает ресурс.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.resource).with_args(remote_directory), raises(RemoteResourceNotFound))
|
||||
assert_that(calling(client.resource).with_args(remote_file), is_not(raises(RemoteResourceNotFound)))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
assert_that(calling(client.check).with_args(remote_path), is_(success())
|
||||
res = client.resource(remote_path)
|
||||
assert_that(res.check())
|
||||
```
|
||||
|
||||
#### Методы ####
|
||||
|
||||
resource API реализует следущие методы: `check`, `clean`, `is_directory`, `rename`, `move`, `copy`, `info`, `read_from`, `read`, `read_async`, `write_to`, `write`, `write_async`, `publish` и `unpublish`.
|
||||
|
||||
|
||||
*Тестовый сценарий 1*
|
||||
|
||||
Идентификатор: 2.2.1
|
||||
Название: Проверка существования ресурса
|
||||
Описание: В случае, если указанный ресурс существует,
|
||||
то результат метода check будет успешным.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
assert_that(calling(client.resource).with_args(remote_path), raises(RemoteResourceNotFound))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
assert_that(calling(client.check).with_args(remote_path), is_(success())
|
||||
res = client.resource(remote_path)
|
||||
assert_that(res.check())
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 2*
|
||||
|
||||
Идентификатор: 2.2.2
|
||||
Название: Удаление ресурса
|
||||
Описание: В случае, если указанный ресурс существует,
|
||||
то метод clean удалит данный ресурс.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
assert_that(calling(res.clean), is_not(raises(RemoteResourceNotFound)))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
assert_that(calling(client.check).with_args(remote_path), is_(success())
|
||||
res = client.resource(remote_path)
|
||||
assert_that(res.check())
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 3*
|
||||
|
||||
Идентификатор: 2.2.3
|
||||
Название: Проверка является ли ресурс директорией
|
||||
Описание: В случае, если указанный ресурс является директорией,
|
||||
то результат метода is_directory будет успешным.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
res = client.resource(remote_file)
|
||||
assert_that(calling(res.is_directory), is_(not_success()))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
res = client.resource(remote_directory)
|
||||
assert_that(calling(res.is_directory), is_(success()))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 4*
|
||||
|
||||
Идентификатор: 2.2.4
|
||||
Название: Переименование ресурса
|
||||
Описание: В случае, если указанный ресурс существует,
|
||||
то метод rename переименует данный ресурс.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
assert_that(calling(res.rename).with_args(new_name), raises(RemoteResourceNotFound))
|
||||
assert_that(calling(res.rename).with_args(new_name), raises(RemoteResourceAlreadyExists))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
res = client.resource(old_path)
|
||||
res.rename(new_name)
|
||||
new_path = res.urn
|
||||
assert_that(calling(client.check).with_args(old_path), is_(not_success()))
|
||||
assert_that(calling(client.check).with_args(new_path), is_(success()))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 5*
|
||||
|
||||
Идентификатор: 2.2.5
|
||||
Название: Перемещение ресурса
|
||||
Описание: В случае, если указанный ресурс существует,
|
||||
то метод move переместит данный ресурс.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
res = client.resource(old_path)
|
||||
assert_that(calling(res.move).with_args(new_path), raises(RemoteResourceNotFound))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
res = client.resource(old_path)
|
||||
res.move(new_path)
|
||||
assert_that(calling(client.check).with_args(old_path), is_(not_success()))
|
||||
assert_that(calling(client.check).with_args(new_path), is_(success()))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 6*
|
||||
|
||||
Идентификатор: 2.2.6
|
||||
Название: Копирование ресурса
|
||||
Описание: В случае, если указанный ресурс существует,
|
||||
то метод copy скопирует данный ресурс.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
assert_that(calling(res.copy).with_args(to_path), raises(RemoteResourceNotFound))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
res.copy(new_path)
|
||||
assert_that(calling(client.check).with_args(remote_path), is_(success()))
|
||||
assert_that(calling(client.check).with_args(new_path), is_(success()))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 7*
|
||||
|
||||
Идентификатор: 2.2.7
|
||||
Название: Получение информации о ресурсе
|
||||
Описание: В случае, если указанный ресурс существует,
|
||||
то метод info возвращает информацию следующего типа:
|
||||
- дата создания;
|
||||
- дата модификации;
|
||||
- размер;
|
||||
- имя.
|
||||
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
assert_that(calling(res.info), raises(RemoteResourceNotFound))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
info = res.info()
|
||||
assert_that(info, has_key("data1"))
|
||||
assert_that(info, has_key("data2"))
|
||||
assert_that(info, has_key("size"))
|
||||
assert_that(info, has_key("name"))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 8*
|
||||
|
||||
Идентификатор: 2.2.8
|
||||
Название: Считывание данных с буфера в ресурс
|
||||
Описание: В случае, если указанный ресурс не является директорией,
|
||||
то метод read_from считывет содержимое буфера и записывает в ресурс.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
res1 = client.resource(remote_file)
|
||||
assert_that(buff, is_(empty))
|
||||
assert_that(calling(res1.read_from).with_args(buff), raises(BufferIsEmpty))
|
||||
|
||||
res2 = client.resource(remote_directory)
|
||||
assert_that(calling(res2.read_from).with_args(buff), raises(ResourceIsNotDirectory))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
res.read_from(buff)
|
||||
res_size = res.info("size")
|
||||
assert_that(buff.size(), equal_to(res_size))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 9*
|
||||
|
||||
Идентификатор: 2.2.9
|
||||
Название: Запись данных в буфер
|
||||
Описание: В случае, если указанный ресурс не является директорией,
|
||||
то метод write_to записывает содержимое ресурса в буфер.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
assert_that(calling(res.write_to).with_args(buff), raises(RemoteResourceNotFound))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
res.write_to(buff)
|
||||
res_size = res.info("size")
|
||||
assert_that(buff.size(), equal_to(res_size))
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 10*
|
||||
|
||||
Идентификатор: 2.2.10
|
||||
Название: Публикация ресурса
|
||||
Описание: В случае, если указанный ресурс существует, то метод publish
|
||||
возвращает публичную ссылку на ресурс.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
assert_that(calling(res.publish), raises(RemoteResourceNotFound))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
assert_that(calling(res.publish), is_not(raises(RemoteResourceNotFound))
|
||||
link = res.publish()
|
||||
assert_that(link, starts_with("http")
|
||||
```
|
||||
|
||||
|
||||
*Тестовый сценарий 11*
|
||||
|
||||
Идентификатор: 2.2.11
|
||||
Название: Отмена публикации ресурса
|
||||
Описание: В случае, если указанный ресурс существует,
|
||||
то метод unpublish отменяет публикацию ресурса.
|
||||
|
||||
<span style="color: red">Красный случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
assert_that(calling(res.unpublish), raises(RemoteResourceNotFound))
|
||||
```
|
||||
|
||||
<span style="color: green">Зеленый случай</span>
|
||||
```python
|
||||
res = client.resource(remote_path)
|
||||
assert_that(calling(res.unpublish).with_args(remote_path), is_not(raises(RemoteResourceNotFound))
|
||||
```
|
|
@ -1 +0,0 @@
|
|||
- [cesterlizi](https://github.com/cesterlizi)
|
9
setup.py
9
setup.py
|
@ -51,12 +51,11 @@ setup(
|
|||
scripts=['wdc'],
|
||||
tests_require=['pytest', 'pyhamcrest', 'junit-xml', 'pytest-allure-adaptor'],
|
||||
cmdclass={'install': Install, 'test': Test},
|
||||
description='Webdav API, resource API и wdc для WebDAV-серверов (Yandex.Disk, Dropbox, Google Disk, Box, 4shared и т.д.)',
|
||||
description='WebDAV client, based on original package https://github.com/designerror/webdav-client-python',
|
||||
long_description=open('README.rst').read(),
|
||||
author='Designerror',
|
||||
author_email='designerror@yandex.ru',
|
||||
url='https://github.com/designerror/webdavclient',
|
||||
download_url='https://github.com/designerror/webdavclient/tarball/master',
|
||||
author='Yuriy Homyakov',
|
||||
author_email='yuriy.homyakov@gmail.com',
|
||||
url='https://github.com/appetito/webdav-client-python-2',
|
||||
license='MIT License',
|
||||
keywords='webdav, client, python, module, library, packet, Yandex.Disk, Dropbox, Google Disk, Box, 4shared',
|
||||
classifiers=[
|
||||
|
|
13
tox.ini
13
tox.ini
|
@ -1,13 +0,0 @@
|
|||
[tox]
|
||||
envlist = py27
|
||||
toxworkdir={toxinidir}/../.tox
|
||||
[testenv]
|
||||
deps=
|
||||
pycurl
|
||||
lxml
|
||||
argcomplete
|
||||
pytest
|
||||
pyhamcrest
|
||||
junit-xml
|
||||
pytest-allure-adaptor
|
||||
commands=python setup.py test -a "--alluredir /var/tmp/allure"
|
2
wdc
2
wdc
|
@ -11,7 +11,7 @@ import subprocess
|
|||
import getpass
|
||||
import argparse
|
||||
import argcomplete
|
||||
from webdav.client import Client, WebDavException, NotConnection, Urn
|
||||
from webdav2.client import Client, WebDavException, NotConnection, Urn
|
||||
from distutils.util import strtobool
|
||||
from base64 import b64decode, b64encode
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue