test_web.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # This file is part of Radicale - CalDAV and CardDAV server
  2. # Copyright © 2018-2019 Unrud <unrud@outlook.com>
  3. #
  4. # This library is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with Radicale. If not, see <http://www.gnu.org/licenses/>.
  16. """
  17. Test web plugin.
  18. """
  19. from radicale.tests import BaseTest
  20. class TestBaseWebRequests(BaseTest):
  21. """Test web plugin."""
  22. def test_internal(self) -> None:
  23. status, headers, _ = self.request("GET", "/.web")
  24. assert status == 302
  25. assert headers.get("Location") == ".web/"
  26. _, answer = self.get("/.web/")
  27. assert answer
  28. self.post("/.web", check=405)
  29. def test_none(self) -> None:
  30. self.configure({"web": {"type": "none"}})
  31. _, answer = self.get("/.web")
  32. assert answer
  33. self.get("/.web/", check=404)
  34. self.post("/.web", check=405)
  35. def test_custom(self) -> None:
  36. """Custom web plugin."""
  37. self.configure({"web": {"type": "radicale.tests.custom.web"}})
  38. _, answer = self.get("/.web")
  39. assert answer == "custom"
  40. _, answer = self.post("/.web", "body content")
  41. assert answer == "echo:body content"