MCPcopy
hub / github.com/aio-libs/aiohttp / test_raise_method_not_allowed

Method test_raise_method_not_allowed

tests/test_urldispatch.py:204–221  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

202 self.assertIs(handler2, info.handler)
203
204 def test_raise_method_not_allowed(self):
205 handler1 = self.make_handler()
206 handler2 = self.make_handler()
207 self.router.add_route('GET', '/', handler1)
208 self.router.add_route('POST', '/', handler2)
209 req = self.make_request('PUT', '/')
210
211 match_info = self.loop.run_until_complete(self.router.resolve(req))
212 self.assertIsInstance(match_info.route, SystemRoute)
213 self.assertEqual({}, match_info)
214
215 with self.assertRaises(HTTPMethodNotAllowed) as ctx:
216 self.loop.run_until_complete(match_info.handler(req))
217
218 exc = ctx.exception
219 self.assertEqual('PUT', exc.method)
220 self.assertEqual(405, exc.status)
221 self.assertEqual({'POST', 'GET'}, exc.allowed_methods)
222
223 def test_raise_method_not_found(self):
224 handler = self.make_handler()

Callers

nothing calls this directly

Calls 5

make_handlerMethod · 0.95
make_requestMethod · 0.95
add_routeMethod · 0.45
resolveMethod · 0.45
handlerMethod · 0.45

Tested by

no test coverage detected