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

Remove global state about configuration and logs

Many things have been changed to make this possible, probably leading to
many hidden bugs waiting to be found.

Related to #122.
This commit is contained in:
Guillaume Ayoub 2016-04-22 11:37:02 +09:00
parent 8ac19ae0fc
commit 2f97d7d1e1
15 changed files with 576 additions and 488 deletions

View file

@ -19,20 +19,24 @@ Radicale tests with simple requests.
"""
import radicale
import logging
import shutil
import tempfile
from radicale import Application, config
from . import BaseTest
from .helpers import get_file_content
class BaseRequests(object):
class BaseRequests:
"""Tests with simple requests."""
storage_type = None
def setup(self):
radicale.config.set("storage", "type", self.storage_type)
self.configuration = config.load()
self.configuration.set("storage", "type", self.storage_type)
self.logger = logging.getLogger("radicale_test")
def test_root(self):
"""GET request at "/"."""
@ -95,30 +99,25 @@ class TestMultiFileSystem(BaseRequests, BaseTest):
storage_type = "multifilesystem"
def setup(self):
"""Setup function for each test."""
super().setup()
self.colpath = tempfile.mkdtemp()
from radicale import storage
storage.FOLDER = self.colpath
self.application = radicale.Application()
self.configuration.set("storage", "filesystem_folder", self.colpath)
self.application = Application(self.configuration, self.logger)
def teardown(self):
"""Teardown function for each test."""
shutil.rmtree(self.colpath)
class TestCustomStorageSystem(BaseRequests, BaseTest):
"""Base class for custom backend tests."""
storage_type = "custom"
storage_type = "tests.custom.storage"
def setup(self):
"""Setup function for each test."""
super().setup()
self.colpath = tempfile.mkdtemp()
radicale.config.set("storage", "type", "tests.custom.storage")
from tests.custom import storage
storage.FOLDER = self.colpath
self.application = radicale.Application()
self.configuration.set("storage", "filesystem_folder", self.colpath)
self.configuration.set("storage", "test_folder", self.colpath)
self.application = Application(self.configuration, self.logger)
def teardown(self):
"""Teardown function for each test."""
shutil.rmtree(self.colpath)