Home / File/ test_main.py — fastapi Source File

test_main.py — fastapi Source File

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

File python FastAPI Applications 4 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  ac5068c6_5f86_7d74_f744_0a82a8c0acc2["test_main.py"]
  15a1dae5_dbcd_2ab7_1dc4_f5ac55e72d8e["app.main"]
  ac5068c6_5f86_7d74_f744_0a82a8c0acc2 --> 15a1dae5_dbcd_2ab7_1dc4_f5ac55e72d8e
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  ac5068c6_5f86_7d74_f744_0a82a8c0acc2 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  ac5068c6_5f86_7d74_f744_0a82a8c0acc2 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"]
  ac5068c6_5f86_7d74_f744_0a82a8c0acc2 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a
  style ac5068c6_5f86_7d74_f744_0a82a8c0acc2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import pytest
from fastapi.testclient import TestClient
from inline_snapshot import snapshot

from .app.main import app

client = TestClient(app)


@pytest.mark.parametrize(
    "path", ["/a/compute", "/a/compute/", "/b/compute", "/b/compute/"]
)
def test_post(path):
    data = {"a": 2, "b": "foo"}
    response = client.post(path, json=data)
    assert response.status_code == 200, response.text
    assert data == response.json()


@pytest.mark.parametrize(
    "path", ["/a/compute", "/a/compute/", "/b/compute", "/b/compute/"]
)
def test_post_invalid(path):
    data = {"a": "bar", "b": "foo"}
    response = client.post(path, json=data)
    assert response.status_code == 422, response.text


def test_openapi_schema():
    response = client.get("/openapi.json")
    assert response.status_code == 200, response.text
    assert response.json() == snapshot(
        {
            "openapi": "3.1.0",
            "info": {"title": "FastAPI", "version": "0.1.0"},
            "paths": {
                "/a/compute": {
                    "post": {
                        "responses": {
                            "200": {
                                "description": "Successful Response",
                                "content": {"application/json": {"schema": {}}},
                            },
                            "422": {
                                "description": "Validation Error",
                                "content": {
                                    "application/json": {
                                        "schema": {
                                            "$ref": "#/components/schemas/HTTPValidationError"
                                        }
                                    }
                                },
                            },
                        },
                        "summary": "Compute",
                        "operationId": "compute_a_compute_post",
                        "requestBody": {
                            "content": {
                                "application/json": {
                                    "schema": {
// ... (97 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does test_main.py do?
test_main.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_main.py?
test_main.py defines 3 function(s): test_openapi_schema, test_post, test_post_invalid.
What does test_main.py depend on?
test_main.py imports 4 module(s): app.main, inline_snapshot, pytest, testclient.py.
Where is test_main.py in the architecture?
test_main.py is located at tests/test_modules_same_name_body/test_main.py (domain: FastAPI, subdomain: Applications, directory: tests/test_modules_same_name_body).

Analyze Your Own Codebase

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

Try Supermodel Free