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

50 lines
1.7 KiB
Python
Raw Permalink Normal View History

2021-12-08 21:45:42 +01:00
# This file is part of Radicale - CalDAV and CardDAV 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.
"""
from radicale.tests import BaseTest
2018-09-04 03:33:42 +02:00
class TestBaseWebRequests(BaseTest):
"""Test web plugin."""
2021-07-26 20:56:47 +02:00
def test_internal(self) -> None:
_, headers, _ = self.request("GET", "/.web", check=302)
assert headers.get("Location") == "/.web/"
_, answer = self.get("/.web/")
2018-09-04 03:33:42 +02:00
assert answer
2020-09-14 18:46:46 +02:00
self.post("/.web", check=405)
2018-09-04 03:33:42 +02:00
2021-07-26 20:56:47 +02:00
def test_none(self) -> None:
2021-12-10 20:54:04 +01:00
self.configure({"web": {"type": "none"}})
_, answer = self.get("/.web")
2018-09-04 03:33:42 +02:00
assert answer
2022-01-18 18:20:16 +01:00
_, headers, _ = self.request("GET", "/.web/", check=302)
assert headers.get("Location") == "/.web"
2020-09-14 18:46:46 +02:00
self.post("/.web", check=405)
2018-09-04 03:33:42 +02:00
2021-07-26 20:56:47 +02:00
def test_custom(self) -> None:
2018-09-04 03:33:42 +02:00
"""Custom web plugin."""
2021-12-10 20:54:04 +01:00
self.configure({"web": {"type": "radicale.tests.custom.web"}})
_, answer = self.get("/.web")
2018-09-04 03:33:42 +02:00
assert answer == "custom"
2020-09-14 18:46:46 +02:00
_, answer = self.post("/.web", "body content")
assert answer == "echo:body content"