Skip to content

Commit

Permalink
Add test for duplicate path url but different methods
Browse files Browse the repository at this point in the history
  • Loading branch information
robd003 committed Jun 28, 2021
1 parent 80f1056 commit 9daa016
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,24 @@ def handler2():
_, handler, params = router.get("/path/to/bar", "three")
assert handler() == "handler2"
assert params == {"foo": "bar"}


def test_identical_path_routes_with_different_methods(handler):
def handler1():
return "handler1"

def handler2():
return "handler2"

router = Router()
router.add("/<foo:path>", handler1, methods=["GET", "OPTIONS"])
router.add("/<foo:path>", handler2, methods=["POST"])
router.finalize()

_, handler, params = router.get("/a-random-path", "GET")
assert handler() == "handler1"
assert params == {"foo": "a-random-path"}

_, handler, params = router.get("/a-random-path", "POST")
assert handler() == "handler2"
assert params == {"foo": "a-random-path"}

0 comments on commit 9daa016

Please sign in to comment.