mirror of
https://github.com/Kozea/Radicale.git
synced 2025-09-15 20:36:55 +00:00
Use module-wide logger and remove logging config
This commit is contained in:
parent
6c9299cf16
commit
54b9995e22
15 changed files with 176 additions and 274 deletions
|
@ -19,24 +19,15 @@ Tests for Radicale.
|
|||
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from io import BytesIO
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
||||
|
||||
logger = logging.getLogger("radicale_test")
|
||||
if not logger.hasHandlers():
|
||||
handler = logging.StreamHandler(sys.stderr)
|
||||
handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
|
||||
logger.addHandler(handler)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
class BaseTest:
|
||||
"""Base class for tests."""
|
||||
logger = logger
|
||||
|
||||
def request(self, method, path, data=None, **args):
|
||||
"""Send a request."""
|
||||
|
|
|
@ -61,7 +61,7 @@ class TestBaseAuthRequests(BaseTest):
|
|||
self.configuration["auth"]["type"] = "htpasswd"
|
||||
self.configuration["auth"]["htpasswd_filename"] = htpasswd_file_path
|
||||
self.configuration["auth"]["htpasswd_encryption"] = htpasswd_encryption
|
||||
self.application = Application(self.configuration, self.logger)
|
||||
self.application = Application(self.configuration)
|
||||
if test_matrix is None:
|
||||
test_matrix = (
|
||||
("tmp", "bepo", 207), ("tmp", "tmp", 401), ("tmp", "", 401),
|
||||
|
@ -131,7 +131,7 @@ class TestBaseAuthRequests(BaseTest):
|
|||
|
||||
def test_remote_user(self):
|
||||
self.configuration["auth"]["type"] = "remote_user"
|
||||
self.application = Application(self.configuration, self.logger)
|
||||
self.application = Application(self.configuration)
|
||||
status, _, answer = self.request(
|
||||
"PROPFIND", "/",
|
||||
"""<?xml version="1.0" encoding="utf-8"?>
|
||||
|
@ -145,7 +145,7 @@ class TestBaseAuthRequests(BaseTest):
|
|||
|
||||
def test_http_x_remote_user(self):
|
||||
self.configuration["auth"]["type"] = "http_x_remote_user"
|
||||
self.application = Application(self.configuration, self.logger)
|
||||
self.application = Application(self.configuration)
|
||||
status, _, answer = self.request(
|
||||
"PROPFIND", "/",
|
||||
"""<?xml version="1.0" encoding="utf-8"?>
|
||||
|
@ -160,7 +160,7 @@ class TestBaseAuthRequests(BaseTest):
|
|||
def test_custom(self):
|
||||
"""Custom authentication."""
|
||||
self.configuration["auth"]["type"] = "tests.custom.auth"
|
||||
self.application = Application(self.configuration, self.logger)
|
||||
self.application = Application(self.configuration)
|
||||
status, _, answer = self.request(
|
||||
"PROPFIND", "/tmp", HTTP_AUTHORIZATION="Basic %s" %
|
||||
base64.b64encode(("tmp:").encode()).decode())
|
||||
|
|
|
@ -1396,7 +1396,7 @@ class BaseRequestsMixIn:
|
|||
self.configuration["auth"]["htpasswd_filename"] = os.devnull
|
||||
self.configuration["auth"]["htpasswd_encryption"] = "plain"
|
||||
self.configuration["rights"]["type"] = "owner_only"
|
||||
self.application = Application(self.configuration, self.logger)
|
||||
self.application = Application(self.configuration)
|
||||
status, headers, _ = self.request("MKCOL", "/user/")
|
||||
assert status in (401, 403)
|
||||
assert headers.get("WWW-Authenticate")
|
||||
|
@ -1479,7 +1479,7 @@ class BaseFileSystemTest(BaseTest):
|
|||
self.configuration["storage"]["filesystem_fsync"] = "False"
|
||||
# Required on Windows, doesn't matter on Unix
|
||||
self.configuration["storage"]["filesystem_close_lock_file"] = "True"
|
||||
self.application = Application(self.configuration, self.logger)
|
||||
self.application = Application(self.configuration)
|
||||
|
||||
def teardown(self):
|
||||
shutil.rmtree(self.colpath)
|
||||
|
|
|
@ -53,7 +53,7 @@ class TestBaseAuthRequests(BaseTest):
|
|||
self.configuration["auth"]["type"] = "htpasswd"
|
||||
self.configuration["auth"]["htpasswd_filename"] = htpasswd_file_path
|
||||
self.configuration["auth"]["htpasswd_encryption"] = "plain"
|
||||
self.application = Application(self.configuration, self.logger)
|
||||
self.application = Application(self.configuration)
|
||||
for u in ("tmp", "other"):
|
||||
status, _, _ = self.request(
|
||||
"PROPFIND", "/%s" % u, HTTP_AUTHORIZATION="Basic %s" %
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue