Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved #986 - implemented router shortcuts #989

Merged
merged 3 commits into from
Jul 24, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added more unittests for all shortcuts
alexm92 committed Jul 23, 2016
commit a76e6b7d0a0bcf367c4aa125c3b0f7db5fddd9e6
40 changes: 40 additions & 0 deletions tests/test_urldispatch.py
Original file line number Diff line number Diff line change
@@ -99,6 +99,46 @@ def test_add_route_with_add_get_shortcut(self):
self.assertIs(handler, info.handler)
self.assertIsNone(info.route.name)

def test_add_route_with_add_post_shortcut(self):
handler = self.make_handler()
self.router.add_post('/handler/to/path', handler)
req = self.make_request('POST', '/handler/to/path')
info = self.loop.run_until_complete(self.router.resolve(req))
self.assertIsNotNone(info)
self.assertEqual(0, len(info))
self.assertIs(handler, info.handler)
self.assertIsNone(info.route.name)

def test_add_route_with_add_put_shortcut(self):
handler = self.make_handler()
self.router.add_put('/handler/to/path', handler)
req = self.make_request('PUT', '/handler/to/path')
info = self.loop.run_until_complete(self.router.resolve(req))
self.assertIsNotNone(info)
self.assertEqual(0, len(info))
self.assertIs(handler, info.handler)
self.assertIsNone(info.route.name)

def test_add_route_with_add_patch_shortcut(self):
handler = self.make_handler()
self.router.add_patch('/handler/to/path', handler)
req = self.make_request('PATCH', '/handler/to/path')
info = self.loop.run_until_complete(self.router.resolve(req))
self.assertIsNotNone(info)
self.assertEqual(0, len(info))
self.assertIs(handler, info.handler)
self.assertIsNone(info.route.name)

def test_add_route_with_add_delete_shortcut(self):
handler = self.make_handler()
self.router.add_delete('/handler/to/path', handler)
req = self.make_request('DELETE', '/handler/to/path')
info = self.loop.run_until_complete(self.router.resolve(req))
self.assertIsNotNone(info)
self.assertEqual(0, len(info))
self.assertIs(handler, info.handler)
self.assertIsNone(info.route.name)

def test_add_with_name(self):
handler = self.make_handler()
self.router.add_route('GET', '/handler/to/path', handler,