Add more tests
This commit is contained in:
parent
d3bb19800c
commit
80e8750c8a
@ -26,5 +26,4 @@ class ApplicationPostMixin:
|
||||
"""Manage POST request."""
|
||||
if path == "/.web" or path.startswith("/.web/"):
|
||||
return self._web.post(environ, base_prefix, path, user)
|
||||
|
||||
return httputils.METHOD_NOT_ALLOWED
|
||||
|
@ -104,8 +104,8 @@ class BaseTest:
|
||||
self._check_status(status, 200, check)
|
||||
return status, answer
|
||||
|
||||
def post(self, path, check=True, **args):
|
||||
status, _, answer = self.request("POST", path, **args)
|
||||
def post(self, path, data=None, check=True, **args):
|
||||
status, _, answer = self.request("POST", path, data, **args)
|
||||
self._check_status(status, 200, check)
|
||||
return status, answer
|
||||
|
||||
|
@ -29,4 +29,5 @@ class Web(web.BaseWeb):
|
||||
return client.OK, {"Content-Type": "text/plain"}, "custom"
|
||||
|
||||
def post(self, environ, base_prefix, path, user):
|
||||
return client.OK, {"Content-Type": "text/plain"}, "custom post"
|
||||
answer = "echo:" + environ["wsgi.input"].read().decode()
|
||||
return client.OK, {"Content-Type": "text/plain"}, answer
|
||||
|
@ -48,6 +48,7 @@ class TestBaseWebRequests(BaseTest):
|
||||
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")
|
||||
@ -55,6 +56,7 @@ class TestBaseWebRequests(BaseTest):
|
||||
_, answer = self.get("/.web")
|
||||
assert answer
|
||||
self.get("/.web/", check=404)
|
||||
self.post("/.web", check=405)
|
||||
|
||||
def test_custom(self):
|
||||
"""Custom web plugin."""
|
||||
@ -63,6 +65,5 @@ class TestBaseWebRequests(BaseTest):
|
||||
self.application = Application(self.configuration)
|
||||
_, answer = self.get("/.web")
|
||||
assert answer == "custom"
|
||||
|
||||
_, answer = self.post("/.web")
|
||||
assert answer == "custom post"
|
||||
_, answer = self.post("/.web", "body content")
|
||||
assert answer == "echo:body content"
|
||||
|
Loading…
Reference in New Issue
Block a user