Allow attach custom storage backend

This commit is contained in:
Sergey Fursov
2013-12-28 14:15:35 +04:00
parent a91a7790c5
commit 3b0328ca1e
6 changed files with 66 additions and 6 deletions

View File

@ -123,6 +123,25 @@ class GitMultiFileSystem(GitFileSystem, MultiFileSystem):
"""Base class for multifilesystem tests using Git"""
class CustomStorageSystem(BaseTest):
"""Base class for custom backend tests."""
storage_type = "custom"
def setup(self):
"""Setup function for each test."""
self.colpath = tempfile.mkdtemp()
config.set("storage", "type", self.storage_type)
config.set("storage", "custom_handler", "tests.custom.storage")
from tests.custom import storage
storage.FOLDER = self.colpath
storage.GIT_REPOSITORY = None
self.application = radicale.Application()
def teardown(self):
"""Teardown function for each test."""
shutil.rmtree(self.colpath)
class AuthSystem(BaseTest):
"""Base class to test Radicale with Htpasswd authentication"""
def setup(self):

30
tests/custom/storage.py Normal file
View File

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
#
# This file is part of Radicale Server - Calendar Server
# Copyright © 2012-2013 Guillaume Ayoub
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Radicale. If not, see <http://www.gnu.org/licenses/>.
"""
Custom storage backend.
Copy of filesystem storage backend for testing
"""
from radicale.storage import filesystem
class Collection(filesystem.Collection):
"""Collection stored in a flat ical file."""

View File

@ -25,6 +25,7 @@ from . import (FileSystem, MultiFileSystem, DataBaseSystem,
GitFileSystem, GitMultiFileSystem)
from .helpers import get_file_content
import sys
from tests import CustomStorageSystem
class BaseRequests(object):
@ -83,7 +84,7 @@ class BaseRequests(object):
# Generate classes with different configs
cl_list = [FileSystem, MultiFileSystem, DataBaseSystem,
GitFileSystem, GitMultiFileSystem]
GitFileSystem, GitMultiFileSystem, CustomStorageSystem]
for cl in cl_list:
classname = "Test%s" % cl.__name__
setattr(sys.modules[__name__],