1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-06-26 16:45:52 +00:00
Radicale/radicale/tests/test_web.py

65 lines
2.1 KiB
Python
Raw Normal View History

2018-09-04 03:33:42 +02:00
# This file is part of Radicale Server - Calendar Server
2019-06-17 04:13:25 +02:00
# Copyright © 2018-2019 Unrud <unrud@outlook.com>
2018-09-04 03:33:42 +02:00
#
# 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/>.
"""
Test web plugin.
"""
import shutil
import tempfile
from radicale import Application, config
from radicale.tests import BaseTest
2018-09-04 03:33:42 +02:00
class TestBaseWebRequests(BaseTest):
"""Test web plugin."""
def setup(self):
self.configuration = config.load()
self.colpath = tempfile.mkdtemp()
2019-06-17 04:13:25 +02:00
self.configuration.update({
"storage": {"filesystem_folder": self.colpath},
# Disable syncing to disk for better performance
"internal": {"filesystem_fsync": "False"}}, "test", internal=True)
2018-09-04 03:33:42 +02:00
self.application = Application(self.configuration)
def teardown(self):
shutil.rmtree(self.colpath)
def test_internal(self):
status, headers, _ = self.request("GET", "/.web")
assert status == 302
assert headers.get("Location") == ".web/"
_, answer = self.get("/.web/")
2018-09-04 03:33:42 +02:00
assert answer
def test_none(self):
2019-06-17 04:13:25 +02:00
self.configuration.update({"web": {"type": "none"}}, "test")
2018-09-04 03:33:42 +02:00
self.application = Application(self.configuration)
_, answer = self.get("/.web")
2018-09-04 03:33:42 +02:00
assert answer
self.get("/.web/", check=404)
2018-09-04 03:33:42 +02:00
def test_custom(self):
"""Custom web plugin."""
2019-06-17 04:13:25 +02:00
self.configuration.update({
2020-01-15 18:44:00 +01:00
"web": {"type": "radicale.tests.custom.web"}}, "test")
2018-09-04 03:33:42 +02:00
self.application = Application(self.configuration)
_, answer = self.get("/.web")
2018-09-04 03:33:42 +02:00
assert answer == "custom"