Esempio n. 1
0
    def test_by_method_default(self):
        app = web.match('/') | web.by_method({
                'DELETE': lambda e,d: Response('delete'),
            },
            default_handler=lambda e,d: Response('default'))

        self.assertEqual(web.ask(app, '/', method="DELETE").body, 'delete')
        self.assertEqual(web.ask(app, '/').body, 'default')
Esempio n. 2
0
    def test_by_method(self):
        app = web.match("/") | web.by_method(
            {"DELETE": lambda e, d: Response("delete"), ("POST", "PUT"): lambda e, d: Response("post")}
        )

        self.assertEqual(web.ask(app, "/", method="PUT").body, "post")
        self.assertEqual(web.ask(app, "/", method="DELETE").body, "delete")
        self.assertEqual(web.ask(app, "/").status_int, 405)
Esempio n. 3
0
    def test_by_method(self):
        app = web.match('/') | web.by_method({
            'DELETE': lambda e,d: Response('delete'),
            ('POST', 'PUT'): lambda e,d: Response('post'),
        })

        self.assertEqual(web.ask(app, '/', method="PUT").body, 'post')
        self.assertEqual(web.ask(app, '/', method="DELETE").body, 'delete')
        self.assertEqual(web.ask(app, '/').status_int, 405)