1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-09-15 20:36:55 +00:00

Cosmetic changes (pylint)

This commit is contained in:
Unrud 2020-01-17 12:45:01 +01:00
parent 7aca052859
commit 0fb02cd026
19 changed files with 85 additions and 105 deletions

View file

@ -57,10 +57,6 @@ class BaseTest:
def request(self, method, path, data=None, **args):
"""Send a request."""
self.application._status = None
self.application._headers = None
self.application._answer = None
for key in args:
args[key.upper()] = args[key]
args["REQUEST_METHOD"] = method.upper()

View file

@ -67,7 +67,7 @@ class TestBaseAuthRequests(BaseTest):
("tmp", "bepo", 207), ("tmp", "tmp", 401), ("tmp", "", 401),
("unk", "unk", 401), ("unk", "", 401), ("", "", 401))
for user, password, expected_status in test_matrix:
status, _, answer = self.request(
status, _, _ = self.request(
"PROPFIND", "/",
HTTP_AUTHORIZATION="Basic %s" % base64.b64encode(
("%s:%s" % (user, password)).encode()).decode())
@ -163,7 +163,7 @@ class TestBaseAuthRequests(BaseTest):
self.configuration.update(
{"auth": {"type": "radicale.tests.custom.auth"}}, "test")
self.application = Application(self.configuration)
status, _, answer = self.request(
status, _, _ = self.request(
"PROPFIND", "/tmp", HTTP_AUTHORIZATION="Basic %s" %
base64.b64encode(("tmp:").encode()).decode())
assert status == 207

View file

@ -1317,7 +1317,7 @@ class BaseRequestsMixIn:
calendar_path = "/calendar.ics/"
status, _, _ = self.request("MKCALENDAR", calendar_path)
assert status == 201
sync_token, xml = self._report_sync_token(
sync_token, _ = self._report_sync_token(
calendar_path, "http://radicale.org/ns/sync/INVALID")
assert not sync_token
@ -1326,13 +1326,12 @@ class BaseRequestsMixIn:
calendar_path = "/calendar.ics/"
status, _, _ = self.request("MKCALENDAR", calendar_path)
assert status == 201
sync_token, xml = self._report_sync_token(calendar_path)
sync_token, _ = self._report_sync_token(calendar_path)
event = get_file_content("event1.ics")
event_path = posixpath.join(calendar_path, "event.ics")
status, _, _ = self.request("PUT", event_path, event)
assert status == 201
new_sync_token, xml = self._report_sync_token(calendar_path,
sync_token)
new_sync_token, _ = self._report_sync_token(calendar_path, sync_token)
assert sync_token != new_sync_token
def test_propfind_same_as_sync_collection_sync_token(self):
@ -1340,9 +1339,8 @@ class BaseRequestsMixIn:
calendar_path = "/calendar.ics/"
status, _, _ = self.request("MKCALENDAR", calendar_path)
assert status == 201
sync_token, xml = self._report_sync_token(calendar_path)
new_sync_token, xml = self._report_sync_token(calendar_path,
sync_token)
sync_token, _ = self._report_sync_token(calendar_path)
new_sync_token, _ = self._report_sync_token(calendar_path, sync_token)
if not self.full_sync_token_support and not new_sync_token:
return
assert sync_token == new_sync_token
@ -1504,9 +1502,9 @@ class TestMultiFileSystem(BaseFileSystemTest, BaseRequestsMixIn):
def test_hook(self):
"""Run hook."""
self.configuration.update({"storage": {"hook": (
"mkdir %s" % os.path.join("collection-root", "created_by_hook"))
}}, "test")
self.configuration.update({"storage": {
"hook": ("mkdir %s" % os.path.join(
"collection-root", "created_by_hook"))}}, "test")
self.application = Application(self.configuration)
status, _, _ = self.request("MKCALENDAR", "/calendar.ics/")
assert status == 201
@ -1515,9 +1513,9 @@ class TestMultiFileSystem(BaseFileSystemTest, BaseRequestsMixIn):
def test_hook_read_access(self):
"""Verify that hook is not run for read accesses."""
self.configuration.update({"storage": {"hook": (
"mkdir %s" % os.path.join("collection-root", "created_by_hook"))
}}, "test")
self.configuration.update({"storage": {
"hook": ("mkdir %s" % os.path.join(
"collection-root", "created_by_hook"))}}, "test")
self.application = Application(self.configuration)
status, _, _ = self.request("PROPFIND", "/")
assert status == 207
@ -1536,9 +1534,9 @@ class TestMultiFileSystem(BaseFileSystemTest, BaseRequestsMixIn):
def test_hook_principal_collection_creation(self):
"""Verify that the hooks runs when a new user is created."""
self.configuration.update({"storage": {"hook": (
"mkdir %s" % os.path.join("collection-root", "created_by_hook"))
}}, "test")
self.configuration.update({"storage": {
"hook": ("mkdir %s" % os.path.join(
"collection-root", "created_by_hook"))}}, "test")
self.application = Application(self.configuration)
status, _, _ = self.request("PROPFIND", "/", HTTP_AUTHORIZATION=(
"Basic " + base64.b64encode(b"user:").decode()))
@ -1633,11 +1631,10 @@ class TestCustomStorageSystem(BaseFileSystemTest):
"""Test custom backend loading."""
storage_type = "radicale.tests.custom.storage_simple_sync"
full_sync_token_support = False
_report_sync_token = BaseRequestsMixIn._report_sync_token
test_root = BaseRequestsMixIn.test_root
# include tests related to sync token
for s in dir(BaseRequestsMixIn):
if s.startswith("test_") and ("_sync_" in s or s.endswith("_sync")):
setattr(TestCustomStorageSystem, s, getattr(BaseRequestsMixIn, s))
_report_sync_token = BaseRequestsMixIn._report_sync_token
# include tests related to sync token
for s in dir(BaseRequestsMixIn):
if s.startswith("test_") and ("_sync_" in s or s.endswith("_sync")):
locals()[s] = getattr(BaseRequestsMixIn, s)
del s

View file

@ -77,7 +77,7 @@ class TestConfig:
with pytest.raises(Exception) as exc_info:
config.load([(config_path, False)])
e = exc_info.value
assert ("Failed to load config file %r" % config_path) in str(e)
assert "Failed to load config file %r" % config_path in str(e)
def test_load_multiple(self):
config_path1 = self._write_config({
@ -142,41 +142,41 @@ class TestConfig:
assert "Invalid section 'internal'" in str(e)
def test_plugin_schema(self):
PLUGIN_SCHEMA = {"auth": {"new_option": {"value": "False",
plugin_schema = {"auth": {"new_option": {"value": "False",
"type": bool}}}
configuration = config.load()
configuration.update({"auth": {"type": "new_plugin"}}, "test")
plugin_configuration = configuration.copy(PLUGIN_SCHEMA)
plugin_configuration = configuration.copy(plugin_schema)
assert plugin_configuration.get("auth", "new_option") is False
configuration.update({"auth": {"new_option": "True"}}, "test")
plugin_configuration = configuration.copy(PLUGIN_SCHEMA)
plugin_configuration = configuration.copy(plugin_schema)
assert plugin_configuration.get("auth", "new_option") is True
def test_plugin_schema_duplicate_option(self):
PLUGIN_SCHEMA = {"auth": {"type": {"value": "False",
plugin_schema = {"auth": {"type": {"value": "False",
"type": bool}}}
configuration = config.load()
with pytest.raises(Exception) as exc_info:
configuration.copy(PLUGIN_SCHEMA)
configuration.copy(plugin_schema)
e = exc_info.value
assert "option already exists in 'auth': 'type'" in str(e)
def test_plugin_schema_invalid(self):
PLUGIN_SCHEMA = {"server": {"new_option": {"value": "False",
plugin_schema = {"server": {"new_option": {"value": "False",
"type": bool}}}
configuration = config.load()
with pytest.raises(Exception) as exc_info:
configuration.copy(PLUGIN_SCHEMA)
configuration.copy(plugin_schema)
e = exc_info.value
assert "not a plugin section: 'server" in str(e)
def test_plugin_schema_option_invalid(self):
PLUGIN_SCHEMA = {"auth": {}}
plugin_schema = {"auth": {}}
configuration = config.load()
configuration.update({"auth": {"type": "new_plugin",
"new_option": False}}, "test")
with pytest.raises(Exception) as exc_info:
configuration.copy(PLUGIN_SCHEMA)
configuration.copy(plugin_schema)
e = exc_info.value
assert "Invalid option 'new_option'" in str(e)
assert "section 'auth'" in str(e)

View file

@ -132,7 +132,7 @@ class TestBaseServerRequests:
self.sockname = sock.getsockname()[:2]
self.configuration.update({
"server": {"hosts": "[%s]:%d" % self.sockname}}, "test")
savedEaiAddrfamily = server.EAI_ADDRFAMILY
original_eai_addrfamily = server.EAI_ADDRFAMILY
if os.name == "nt" and server.EAI_ADDRFAMILY is None:
# HACK: incomplete errno conversion in WINE
server.EAI_ADDRFAMILY = -9
@ -140,7 +140,7 @@ class TestBaseServerRequests:
self.thread.start()
status, _, _ = self.request("GET", "/")
finally:
server.EAI_ADDRFAMILY = savedEaiAddrfamily
server.EAI_ADDRFAMILY = original_eai_addrfamily
assert status == 302
def test_command_line_interface(self):