Пример #1
0
    def test_known_HTTP_methods_use_associated_renderer(self):
        render = traversal.method_delegate(
            GET=lambda request: b"foo",
            put=lambda request: request.method,
        )
        get = Request(url=URL(path=[u""]), method=b"GET")
        self.assertEqual(render(get), b"foo")

        put = Request(url=URL(path=[u""]), method=b"PUT")
        self.assertEqual(render(put), b"PUT")
Пример #2
0
    def test_known_HTTP_methods_use_associated_renderer(self):
        render = traversal.method_delegate(
            GET=lambda request: b"foo",
            put=lambda request: request.method,
        )
        get = Request(url=URL(path=[u""]), method=b"GET")
        self.assertEqual(render(get), b"foo")

        put = Request(url=URL(path=[u""]), method=b"PUT")
        self.assertEqual(render(put), b"PUT")
Пример #3
0
 def test_unknown_HTTP_methods_return_405s(self):
     render = traversal.method_delegate(get=lambda _: b"foo")
     request = Request(url=URL(path=[u""]), method=b"PUT")
     self.assertEqual(render(request).code, 405)
Пример #4
0
 def test_unknown_HTTP_methods_return_405s(self):
     render = traversal.method_delegate(get=lambda _: b"foo")
     request = Request(url=URL(path=[u""]), method=b"PUT")
     self.assertEqual(render(request).code, 405)