Home / File/ test_router_redirect_slashes.py — fastapi Source File

test_router_redirect_slashes.py — fastapi Source File

Architecture documentation for test_router_redirect_slashes.py, a python file in the fastapi codebase. 2 imports, 0 dependents.

File python FastAPI Routing 2 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  9571fa53_d8df_c88f_e0ba_c0a461963893["test_router_redirect_slashes.py"]
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  9571fa53_d8df_c88f_e0ba_c0a461963893 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  9571fa53_d8df_c88f_e0ba_c0a461963893 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  style 9571fa53_d8df_c88f_e0ba_c0a461963893 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from fastapi import APIRouter, FastAPI
from fastapi.testclient import TestClient


def test_redirect_slashes_enabled():
    app = FastAPI()
    router = APIRouter()

    @router.get("/hello/")
    def hello_page() -> str:
        return "Hello, World!"

    app.include_router(router)

    client = TestClient(app)

    response = client.get("/hello/", follow_redirects=False)
    assert response.status_code == 200

    response = client.get("/hello", follow_redirects=False)
    assert response.status_code == 307


def test_redirect_slashes_disabled():
    app = FastAPI(redirect_slashes=False)
    router = APIRouter()

    @router.get("/hello/")
    def hello_page() -> str:
        return "Hello, World!"

    app.include_router(router)

    client = TestClient(app)

    response = client.get("/hello/", follow_redirects=False)
    assert response.status_code == 200

    response = client.get("/hello", follow_redirects=False)
    assert response.status_code == 404

Domain

Subdomains

Frequently Asked Questions

What does test_router_redirect_slashes.py do?
test_router_redirect_slashes.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Routing subdomain.
What functions are defined in test_router_redirect_slashes.py?
test_router_redirect_slashes.py defines 2 function(s): test_redirect_slashes_disabled, test_redirect_slashes_enabled.
What does test_router_redirect_slashes.py depend on?
test_router_redirect_slashes.py imports 2 module(s): __init__.py, testclient.py.
Where is test_router_redirect_slashes.py in the architecture?
test_router_redirect_slashes.py is located at tests/test_router_redirect_slashes.py (domain: FastAPI, subdomain: Routing, directory: tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free