Skip to content

Commit

Permalink
Improve docs and cleanup coverage reports
Browse files Browse the repository at this point in the history
  • Loading branch information
mar10 committed May 14, 2023
1 parent ee85e7f commit 8df2f0e
Show file tree
Hide file tree
Showing 8 changed files with 536 additions and 455 deletions.
5 changes: 3 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "*"
Expand Down
945 changes: 509 additions & 436 deletions Pipfile.lock

Large diffs are not rendered by default.

Empty file added report.html
Empty file.
2 changes: 2 additions & 0 deletions sample_wsgidav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
13 changes: 8 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,30 @@ 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]
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]
Expand Down
7 changes: 4 additions & 3 deletions wsgidav/server/server_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 7 additions & 7 deletions wsgidav/server/server_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "."
Expand All @@ -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
Expand All @@ -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}"
)
Expand All @@ -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()

Expand Down
5 changes: 3 additions & 2 deletions wsgidav/wsgidav_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ def __init__(self, config):

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)
Expand All @@ -158,6 +158,7 @@ def __init__(self, config):
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)):
Expand Down

0 comments on commit 8df2f0e

Please sign in to comment.