diff --git a/.travis.yml b/.travis.yml index 97caea6..458c2f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,13 +5,6 @@ python: - 3.4 - 3.5 -install: - - pip install sqlalchemy - - pip install nose-cov - - pip install pam - - pip install requests - - pip install dulwich - script: nosetests sudo: false diff --git a/radicale/__init__.py b/radicale/__init__.py index ee36d2c..6e13cd2 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -381,13 +381,7 @@ class Application(object): def do_GET(self, environ, read_collections, write_collections, content, user): - """Manage GET request. - - In Radicale, GET requests create collections when the URL is not - available. This is useful for clients with no MKCOL or MKCALENDAR - support. - - """ + """Manage GET request.""" # Display a "Radicale works!" message if the root URL is requested if environ["PATH_INFO"] == "/": headers = {"Content-type": "text/html"} diff --git a/radicale/storage.py b/radicale/storage.py index 8f07904..6deb328 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -123,7 +123,7 @@ class Collection(ical.Collection): filenames = os.listdir(self._filesystem_path) except (OSError, IOError) as e: log.LOGGER.info( - 'Error while reading collection %r: %r' % ( + "Error while reading collection %r: %r" % ( self._filesystem_path, e)) return "" @@ -134,7 +134,7 @@ class Collection(ical.Collection): items.update(self._parse(fd.read(), components)) except (OSError, IOError) as e: log.LOGGER.warning( - 'Error while reading item %r: %r' % (path, e)) + "Error while reading item %r: %r" % (path, e)) return ical.serialize( self.tag, self.headers, sorted(items.values(), key=lambda x: x.name)) @@ -164,7 +164,8 @@ class Collection(ical.Collection): def is_leaf(cls, path): filesystem_path = pathutils.path_to_filesystem(path, FOLDER) return ( - os.path.isdir(filesystem_path) and os.path.exists(path + ".props")) + os.path.isdir(filesystem_path) and + os.path.exists(filesystem_path + ".props")) @property def last_modified(self): diff --git a/tests/custom/storage.py b/tests/custom/storage.py index 70e9872..4c5d072 100644 --- a/tests/custom/storage.py +++ b/tests/custom/storage.py @@ -21,8 +21,8 @@ Copy of filesystem storage backend for testing """ -from radicale.storage import filesystem +from radicale import storage -class Collection(filesystem.Collection): - """Collection stored in a flat ical file.""" +class Collection(storage.Collection): + """Collection stored in a folder.""" diff --git a/tests/test_auth.py b/tests/test_auth.py index 7b9163d..067cffd 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -26,8 +26,7 @@ import os import radicale import tempfile -from radicale import config -from radicale.auth import htpasswd +from radicale import config, auth from . import BaseTest @@ -55,8 +54,8 @@ class TestBaseAuthRequests(BaseTest): hashlib.sha1(b"bepo").digest())) config.set("auth", "type", "htpasswd") - htpasswd.FILENAME = htpasswd_file_path - htpasswd.ENCRYPTION = "sha1" + auth.FILENAME = htpasswd_file_path + auth.ENCRYPTION = "sha1" self.application = radicale.Application() @@ -67,8 +66,7 @@ class TestBaseAuthRequests(BaseTest): def test_custom(self): """Custom authentication.""" - config.set("auth", "type", "custom") - config.set("auth", "custom_handler", "tests.custom.auth") + config.set("auth", "type", "tests.custom.auth") self.application = radicale.Application() status, headers, answer = self.request( "GET", "/", HTTP_AUTHORIZATION=self.userpass) diff --git a/tests/test_base.py b/tests/test_base.py index eb63dc0..04dbb40 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -23,10 +23,6 @@ import radicale import shutil import tempfile -from dulwich.repo import Repo -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker - from . import BaseTest from .helpers import get_file_content @@ -44,15 +40,16 @@ class BaseRequests(object): assert status == 200 assert "Radicale works!" in answer # Test the creation of the collection + self.request( + "PUT", "/calendar.ics/", "BEGIN:VCALENDAR\r\nEND:VCALENDAR") status, headers, answer = self.request("GET", "/calendar.ics/") assert "BEGIN:VCALENDAR" in answer - #assert "VERSION:2.0" in answer assert "END:VCALENDAR" in answer - #assert "PRODID:-//Radicale//NONSGML Radicale Server//EN" in answer def test_add_event(self): """Add an event.""" - self.request("GET", "/calendar.ics/") + self.request( + "PUT", "/calendar.ics/", "BEGIN:VCALENDAR\r\nEND:VCALENDAR") event = get_file_content("event.ics") path = "/calendar.ics/event.ics" status, headers, answer = self.request("PUT", path, event) @@ -66,7 +63,8 @@ class BaseRequests(object): def test_add_todo(self): """Add a todo.""" - self.request("GET", "/calendar.ics/") + self.request( + "PUT", "/calendar.ics/", "BEGIN:VCALENDAR\r\nEND:VCALENDAR") todo = get_file_content("todo.ics") path = "/calendar.ics/todo.ics" status, headers, answer = self.request("PUT", path, todo) @@ -79,7 +77,8 @@ class BaseRequests(object): def test_delete(self): """Delete an event.""" - self.request("GET", "/calendar.ics/") + self.request( + "PUT", "/calendar.ics/", "BEGIN:VCALENDAR\r\nEND:VCALENDAR") event = get_file_content("event.ics") path = "/calendar.ics/event.ics" status, headers, answer = self.request("PUT", path, event) @@ -91,16 +90,15 @@ class BaseRequests(object): assert "VEVENT" not in answer -class TestFileSystem(BaseRequests, BaseTest): +class TestMultiFileSystem(BaseRequests, BaseTest): """Base class for filesystem tests.""" - storage_type = "filesystem" + storage_type = "multifilesystem" def setup(self): """Setup function for each test.""" self.colpath = tempfile.mkdtemp() - from radicale.storage import filesystem - filesystem.FOLDER = self.colpath - filesystem.GIT_REPOSITORY = None + from radicale import storage + storage.FOLDER = self.colpath self.application = radicale.Application() def teardown(self): @@ -108,40 +106,6 @@ class TestFileSystem(BaseRequests, BaseTest): shutil.rmtree(self.colpath) -class TestMultiFileSystem(TestFileSystem): - """Base class for multifilesystem tests.""" - storage_type = "multifilesystem" - - -class TestDataBaseSystem(BaseRequests, BaseTest): - """Base class for database tests""" - storage_type = "database" - - def setup(self): - super().setup() - radicale.config.set("storage", "database_url", "sqlite://") - from radicale.storage import database - database.Session = sessionmaker() - database.Session.configure(bind=create_engine("sqlite://")) - session = database.Session() - for st in get_file_content("schema.sql").split(";"): - session.execute(st) - session.commit() - self.application = radicale.Application() - - class TestGitFileSystem(TestFileSystem): - """Base class for filesystem tests using Git""" - def setup(self): - super().setup() - Repo.init(self.colpath) - from radicale.storage import filesystem - filesystem.GIT_REPOSITORY = Repo(self.colpath) - - - class TestGitMultiFileSystem(TestGitFileSystem, TestMultiFileSystem): - """Base class for multifilesystem tests using Git""" - - class TestCustomStorageSystem(BaseRequests, BaseTest): """Base class for custom backend tests.""" storage_type = "custom" @@ -150,8 +114,7 @@ class TestCustomStorageSystem(BaseRequests, BaseTest): """Setup function for each test.""" super().setup() self.colpath = tempfile.mkdtemp() - radicale.config.set( - "storage", "custom_handler", "tests.custom.storage") + radicale.config.set("storage", "type", "tests.custom.storage") from tests.custom import storage storage.FOLDER = self.colpath storage.GIT_REPOSITORY = None