Home / File/ test_tutorial002.py — fastapi Source File

test_tutorial002.py — fastapi Source File

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

File python FastAPI Routing 5 imports 5 functions

Entity Profile

Dependency Diagram

graph LR
  a6788c5d_0ba3_0175_27ee_0487b3d446bc["test_tutorial002.py"]
  af9b440f_13c4_d91e_f8ae_bfe199b060d2["os"]
  a6788c5d_0ba3_0175_27ee_0487b3d446bc --> af9b440f_13c4_d91e_f8ae_bfe199b060d2
  b3e303a2_3f2d_638d_930c_3a5dcc2f5a42["pathlib"]
  a6788c5d_0ba3_0175_27ee_0487b3d446bc --> b3e303a2_3f2d_638d_930c_3a5dcc2f5a42
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  a6788c5d_0ba3_0175_27ee_0487b3d446bc --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  a6788c5d_0ba3_0175_27ee_0487b3d446bc --> a7c04dee_ee23_5891_b185_47ff6bed036d
  fc26af4f_37d9_e0c9_cad9_51ee06effde8["tutorial002_py39.py"]
  a6788c5d_0ba3_0175_27ee_0487b3d446bc --> fc26af4f_37d9_e0c9_cad9_51ee06effde8
  style a6788c5d_0ba3_0175_27ee_0487b3d446bc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import os
from pathlib import Path

import pytest
from fastapi.testclient import TestClient


@pytest.fixture(scope="module")
def client():
    static_dir: Path = Path(os.getcwd()) / "static"
    print(static_dir)
    static_dir.mkdir(exist_ok=True)
    from docs_src.custom_docs_ui.tutorial002_py39 import app

    with TestClient(app) as client:
        yield client
    static_dir.rmdir()


def test_swagger_ui_html(client: TestClient):
    response = client.get("/docs")
    assert response.status_code == 200, response.text
    assert "/static/swagger-ui-bundle.js" in response.text
    assert "/static/swagger-ui.css" in response.text


def test_swagger_ui_oauth2_redirect_html(client: TestClient):
    response = client.get("/docs/oauth2-redirect")
    assert response.status_code == 200, response.text
    assert "window.opener.swaggerUIRedirectOauth2" in response.text


def test_redoc_html(client: TestClient):
    response = client.get("/redoc")
    assert response.status_code == 200, response.text
    assert "/static/redoc.standalone.js" in response.text


def test_api(client: TestClient):
    response = client.get("/users/john")
    assert response.status_code == 200, response.text
    assert response.json()["message"] == "Hello john"

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does test_tutorial002.py do?
test_tutorial002.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_tutorial002.py?
test_tutorial002.py defines 5 function(s): client, test_api, test_redoc_html, test_swagger_ui_html, test_swagger_ui_oauth2_redirect_html.
What does test_tutorial002.py depend on?
test_tutorial002.py imports 5 module(s): os, pathlib, pytest, testclient.py, tutorial002_py39.py.
Where is test_tutorial002.py in the architecture?
test_tutorial002.py is located at tests/test_tutorial/test_custom_docs_ui/test_tutorial002.py (domain: FastAPI, subdomain: Routing, directory: tests/test_tutorial/test_custom_docs_ui).

Analyze Your Own Codebase

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

Try Supermodel Free