Improve docs and cleanup coverage reports

This commit is contained in:
Martin Wendt 2023-05-14 13:09:30 +02:00
parent ee85e7fd51
commit 8df2f0ec1a
8 changed files with 540 additions and 459 deletions

View file

@ -14,8 +14,9 @@ isort = "*"
mypy = "*"
Paste = "*" # "~=2.0"
pylint = "*"
pytest = "*" # "~=4.6"
pytest-cov = "*" # "~=2.10"
pytest = "*" # "~=7.3"
pytest-cov = "*" # "~=4.0"
pytest-html = "*"
python-pam = "*" # "~=1.8"
pywin32 = {version = "*", os_name = "== 'nt'"}
recommonmark = "*"

953
Pipfile.lock generated

File diff suppressed because it is too large Load diff

0
report.html Normal file
View file

View file

@ -293,6 +293,8 @@ lock_storage: true
verbose: 3
logging:
#: Enable logging when using wsgidav in library mode (always on, when running as CLI)
enable: null
#: Set logging output format
#: (see https://docs.python.org/3/library/logging.html#logging.Formatter)
logger_date_format: '%H:%M:%S'

13
tox.ini
View file

@ -41,13 +41,14 @@ deps =
requests
webtest
setenv =
COVERAGE_FILE = .coverage.{envname}
COVERAGE_FILE = build/.coverage.{envname}
commands =
# Run everything from /tests folder:
python -V
pip list
# Note: also honors .coveragerc:
pytest -ra -v -x --cov=wsgidav --durations=10 --html=build/pytest/report-{envname}.html --self-contained-html {posargs}
;pytest -ra -v -x --cov=wsgidav --durations=10 --html=build/pytest/report-{envname}.html --self-contained-html {posargs}
pytest -ra -v -x --cov=wsgidav --durations=10 {posargs}
[testenv:coverage]
@ -55,13 +56,15 @@ skip_install = true
deps =
coverage
setenv =
COVERAGE_FILE = .coverage
COVERAGE_FILE = build/.coverage
commands =
coverage erase
coverage combine
coverage html
# ENCODING ERRORS ON Windonws: See
# https://github.com/pytest-dev/pytest-html/issues/336#issuecomment-1546864331
coverage html --directory=build --ignore-errors
; coverage xml
coverage report --fail-under=30.0
coverage report --fail-under=30.0 --skip-empty --ignore-errors
[testenv:mypy]

View file

@ -436,9 +436,10 @@ def _run_cheroot(app, config, _server):
_logger.error("Try `pip install cheroot`.")
return False
org_version = wsgi.Server.version
version = f"WsgiDAV/{__version__} {org_version} Python {util.PYTHON_VERSION}"
wsgi.Server.version = version
version = (
f"WsgiDAV/{__version__} {wsgi.Server.version} Python/{util.PYTHON_VERSION}"
)
# wsgi.Server.version = version
info = _get_common_info(config)

View file

@ -5,12 +5,12 @@
"""
Simple example how to a run WsgiDAV in a 3rd-party WSGI server.
"""
from cheroot import wsgi
from wsgidav import __version__, util
from wsgidav.fs_dav_provider import FilesystemProvider
from wsgidav.wsgidav_app import WsgiDAVApp
__docformat__ = "reStructuredText"
def main():
root_path = "."
@ -24,8 +24,9 @@ def main():
"domain_controller": None # None: dc.simple_dc.SimpleDomainController(user_mapping)
},
"simple_dc": {"user_mapping": {"*": True}}, # anonymous access
"verbose": 1,
"verbose": 4,
"logging": {
"enable": True,
"enable_loggers": [],
},
"property_manager": True, # True: use property_manager.PropertyManager
@ -34,9 +35,6 @@ def main():
app = WsgiDAVApp(config)
# For an example, use cheroot:
from cheroot import wsgi
version = (
f"WsgiDAV/{__version__} {wsgi.Server.version} Python/{util.PYTHON_VERSION}"
)
@ -48,10 +46,12 @@ def main():
# "numthreads": 50,
)
app.logger.info(f"Running {version}")
app.logger.info(f"Serving on http://{config['host']}:{config['port']}/ ...")
try:
server.start()
except KeyboardInterrupt:
print("Caught Ctrl-C, shutting down...")
app.logger.info("Received Ctrl-C: stopping...")
finally:
server.stop()

View file

@ -142,10 +142,10 @@ class WsgiDAVApp:
if config["logging"].get("enable") is not False:
util.init_logging(config)
expand = {"${application}": self}
self.logger = util._logger
# Evaluate configuration and set defaults
expand = {"${application}": self}
_check_config(config)
self.verbose = config.get("verbose", 3)
@ -158,6 +158,7 @@ class WsgiDAVApp:
self.unquote_path_info = hotfixes.get("unquote_path_info", False)
lock_storage = config.get("lock_storage")
if lock_storage is True:
lock_storage = LockStorageDict()
elif isinstance(lock_storage, (str, dict)):