mirror of
https://github.com/Kozea/Radicale.git
synced 2025-10-03 21:20:45 +00:00
Synced with origin
This commit is contained in:
parent
9b3bb2de2b
commit
cf81d1f9a7
94 changed files with 5096 additions and 3560 deletions
|
@ -1,4 +1,4 @@
|
|||
# This file is part of Radicale Server - Calendar Server
|
||||
# This file is part of Radicale - CalDAV and CardDAV server
|
||||
# Copyright © 2018-2019 Unrud <unrud@outlook.com>
|
||||
#
|
||||
# This library is free software: you can redistribute it and/or modify
|
||||
|
@ -19,47 +19,31 @@ Test web plugin.
|
|||
|
||||
"""
|
||||
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
from radicale import Application, config
|
||||
from radicale.tests import BaseTest
|
||||
|
||||
|
||||
class TestBaseWebRequests(BaseTest):
|
||||
"""Test web plugin."""
|
||||
|
||||
def setup(self):
|
||||
self.configuration = config.load()
|
||||
self.colpath = tempfile.mkdtemp()
|
||||
self.configuration.update({
|
||||
"storage": {"filesystem_folder": self.colpath,
|
||||
# Disable syncing to disk for better performance
|
||||
"_filesystem_fsync": "False"}},
|
||||
"test", privileged=True)
|
||||
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/"
|
||||
def test_internal(self) -> None:
|
||||
_, headers, _ = self.request("GET", "/.web", check=302)
|
||||
assert headers.get("Location") == "/.web/"
|
||||
_, answer = self.get("/.web/")
|
||||
assert answer
|
||||
self.post("/.web", check=405)
|
||||
|
||||
def test_none(self):
|
||||
self.configuration.update({"web": {"type": "none"}}, "test")
|
||||
self.application = Application(self.configuration)
|
||||
def test_none(self) -> None:
|
||||
self.configure({"web": {"type": "none"}})
|
||||
_, answer = self.get("/.web")
|
||||
assert answer
|
||||
self.get("/.web/", check=404)
|
||||
_, headers, _ = self.request("GET", "/.web/", check=302)
|
||||
assert headers.get("Location") == "/.web"
|
||||
self.post("/.web", check=405)
|
||||
|
||||
def test_custom(self):
|
||||
def test_custom(self) -> None:
|
||||
"""Custom web plugin."""
|
||||
self.configuration.update({
|
||||
"web": {"type": "radicale.tests.custom.web"}}, "test")
|
||||
self.application = Application(self.configuration)
|
||||
self.configure({"web": {"type": "radicale.tests.custom.web"}})
|
||||
_, answer = self.get("/.web")
|
||||
assert answer == "custom"
|
||||
_, answer = self.post("/.web", "body content")
|
||||
assert answer == "echo:body content"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue