()
| 460 | |
| 461 | |
| 462 | def test_dispatch(): |
| 463 | env = create_environ("/") |
| 464 | map = r.Map([r.Rule("/", endpoint="root"), r.Rule("/foo/", endpoint="foo")]) |
| 465 | adapter = map.bind_to_environ(env) |
| 466 | |
| 467 | raise_this = None |
| 468 | |
| 469 | def view_func(endpoint, values): |
| 470 | if raise_this is not None: |
| 471 | raise raise_this |
| 472 | return Response(repr((endpoint, values))) |
| 473 | |
| 474 | def dispatch(path, quiet=False): |
| 475 | return Response.force_type( |
| 476 | adapter.dispatch(view_func, path, catch_http_exceptions=quiet), env |
| 477 | ) |
| 478 | |
| 479 | assert dispatch("/").data == b"('root', {})" |
| 480 | assert dispatch("/foo").status_code == 308 |
| 481 | raise_this = NotFound() |
| 482 | pytest.raises(NotFound, lambda: dispatch("/bar")) |
| 483 | assert dispatch("/bar", True).status_code == 404 |
| 484 | |
| 485 | |
| 486 | def test_http_host_before_server_name(): |
nothing calls this directly
no test coverage detected