Home / File/ test_regex_deprecated_params.py — fastapi Source File

test_regex_deprecated_params.py — fastapi Source File

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

File python FastAPI Applications 8 imports 5 functions

Entity Profile

Dependency Diagram

graph LR
  3115589e_a081_ce28_ae94_1ef83d2bd277["test_regex_deprecated_params.py"]
  8fd7072e_05b0_6622_0f14_e1e357032855["utils.py"]
  3115589e_a081_ce28_ae94_1ef83d2bd277 --> 8fd7072e_05b0_6622_0f14_e1e357032855
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  3115589e_a081_ce28_ae94_1ef83d2bd277 --> 0dda2280_3359_8460_301c_e98c77e78185
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  3115589e_a081_ce28_ae94_1ef83d2bd277 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  3115589e_a081_ce28_ae94_1ef83d2bd277 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  01c652c5_d85c_f45e_848e_412c94ea4172["exceptions.py"]
  3115589e_a081_ce28_ae94_1ef83d2bd277 --> 01c652c5_d85c_f45e_848e_412c94ea4172
  188b7cd0_ba07_6be7_094a_820e577cc47b["FastAPIDeprecationWarning"]
  3115589e_a081_ce28_ae94_1ef83d2bd277 --> 188b7cd0_ba07_6be7_094a_820e577cc47b
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  3115589e_a081_ce28_ae94_1ef83d2bd277 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"]
  3115589e_a081_ce28_ae94_1ef83d2bd277 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a
  style 3115589e_a081_ce28_ae94_1ef83d2bd277 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import Annotated

import pytest
from fastapi import FastAPI, Query
from fastapi.exceptions import FastAPIDeprecationWarning
from fastapi.testclient import TestClient
from inline_snapshot import snapshot

from .utils import needs_py310


def get_client():
    app = FastAPI()
    with pytest.warns(FastAPIDeprecationWarning):

        @app.get("/items/")
        async def read_items(
            q: Annotated[str | None, Query(regex="^fixedquery$")] = None,
        ):
            if q:
                return f"Hello {q}"
            else:
                return "Hello World"

    client = TestClient(app)
    return client


@needs_py310
def test_query_params_str_validations_no_query():
    client = get_client()
    response = client.get("/items/")
    assert response.status_code == 200
    assert response.json() == "Hello World"


@needs_py310
def test_query_params_str_validations_q_fixedquery():
    client = get_client()
    response = client.get("/items/", params={"q": "fixedquery"})
    assert response.status_code == 200
    assert response.json() == "Hello fixedquery"


@needs_py310
def test_query_params_str_validations_item_query_nonregexquery():
    client = get_client()
    response = client.get("/items/", params={"q": "nonregexquery"})
    assert response.status_code == 422
    assert response.json() == {
        "detail": [
            {
                "type": "string_pattern_mismatch",
                "loc": ["query", "q"],
                "msg": "String should match pattern '^fixedquery$'",
                "input": "nonregexquery",
                "ctx": {"pattern": "^fixedquery$"},
            }
        ]
    }
// ... (87 more lines)

Domain

Subdomains

Frequently Asked Questions

What does test_regex_deprecated_params.py do?
test_regex_deprecated_params.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Applications subdomain.
What functions are defined in test_regex_deprecated_params.py?
test_regex_deprecated_params.py defines 5 function(s): get_client, test_openapi_schema, test_query_params_str_validations_item_query_nonregexquery, test_query_params_str_validations_no_query, test_query_params_str_validations_q_fixedquery.
What does test_regex_deprecated_params.py depend on?
test_regex_deprecated_params.py imports 8 module(s): FastAPIDeprecationWarning, __init__.py, exceptions.py, inline_snapshot, pytest, testclient.py, typing, utils.py.
Where is test_regex_deprecated_params.py in the architecture?
test_regex_deprecated_params.py is located at tests/test_regex_deprecated_params.py (domain: FastAPI, subdomain: Applications, directory: tests).

Analyze Your Own Codebase

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

Try Supermodel Free