Comments (8)
@Holt59 I have changed a way to support servers that do not support HEAD method, now in develop branch there are no requests in the constructor. Soon it will be released
from webdav-client-python-3.
Can you provide an example of dumbing URLs?
And why is it impossible to add dumb for method OPTIONS with return 200 and HEADER “Allow: HEAD”?
from webdav-client-python-3.
Any URL that does not exists, e.g.:
client = Client({
"webdav_hostname": "https://webdav",
"webdav_user": "user",
"webdav_login": "login"
})
I have classes that have a _client
member which is a Client
object constructed during initialization, e.g.:
class A:
def __init__(self, url):
self._client = Client({"webdav_hostname": url})
Before this change, it was possible to perform unit-testing on class A
using dumb URL because the Client
constructor did not perform any operation:
def test_A_foo():
a = A(url="https://webdav")
assert a.foo() == 3
Now it is impossible because the A(...)
initialization will fail, and setting-up a WebDAV client for unit-testing is kind of overkill, especially if I do not use it.
from webdav-client-python-3.
In your case, I can suggest trying to use patch
from unittest.mock like:
@mock.patch("webdav3.client.Client")
def test_A_foo(mock_client):
a = A(url="https://webdav")
assert a.foo() == 3
It mocks the webdav3.client.Client in this method and put mock object as argument.
I think it solves your problem.
from webdav-client-python-3.
@Holt59 Is your problem resolved?
from webdav-client-python-3.
@ezhov-evgeny I'm sorry, I'm not using unittest
but pytest
and I did not have time to check if pytest
offers something similar.
Currently, I've switched-back to the 0.13
version of the package.
But unit-testing aside, I think it would be a good thing to not perform a HTTP request in the Client
constructor, or at least document it a bit more and allow to defer it.
from webdav-client-python-3.
For pytest I can suggest you https://github.com/pytest-dev/pytest-mock/
Actually now I think this request should be in the constructor but I'll think about it
from webdav-client-python-3.
@Holt59 Just released 3.14 try this version
from webdav-client-python-3.
Related Issues (20)
- Verbose does?
- Support setting port number
- download functions on .txt files HOT 1
- delme
- Missing support for username-only authentication HOT 2
- Missing support for bulk PROPFIND requests
- upload_sync did not work correctly HOT 1
- webdav3.exceptions.MethodNotSupported HOT 1
- AttributeError: 'Client' object has no attribute 'publish'
- what's the point to HEAD the parent folder before uploading
- Deleting requires removing self.webdav.root from list results and not re-encoding (corrupting) encoded items.
- Reading the response doesn't handle exception(s) raised by requests
- Move to GitHub Actions CI/CD
- Remote resource not found
- Names are not retrieved for WebDav servers that use displayName in their response XML
- Migrate to GitHub Actions CI/CD HOT 1
- Update the `check` function to support using the `PROPFIND` method for checking
- Please make a new release in PyPI
- Can list() files, but cannot download. "Remote resource not found" HOT 1
- Release 3.14.6 doesn't work when trying to list() with get_info = True HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webdav-client-python-3.