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. 6 imports, 0 dependents.

File python FastAPI Applications 6 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  8af66856_598c_44f4_0b78_7e38035ec150["test_tutorial002.py"]
  46867ee1_f6d2_6a04_13fe_7cd0654020f4["utils"]
  8af66856_598c_44f4_0b78_7e38035ec150 --> 46867ee1_f6d2_6a04_13fe_7cd0654020f4
  83e01a9c_50a9_bec9_6f86_8e729106de01["importlib"]
  8af66856_598c_44f4_0b78_7e38035ec150 --> 83e01a9c_50a9_bec9_6f86_8e729106de01
  af9b440f_13c4_d91e_f8ae_bfe199b060d2["os"]
  8af66856_598c_44f4_0b78_7e38035ec150 --> af9b440f_13c4_d91e_f8ae_bfe199b060d2
  b3e303a2_3f2d_638d_930c_3a5dcc2f5a42["pathlib"]
  8af66856_598c_44f4_0b78_7e38035ec150 --> b3e303a2_3f2d_638d_930c_3a5dcc2f5a42
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  8af66856_598c_44f4_0b78_7e38035ec150 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  8af66856_598c_44f4_0b78_7e38035ec150 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  style 8af66856_598c_44f4_0b78_7e38035ec150 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import importlib
import os
from pathlib import Path

import pytest
from fastapi.testclient import TestClient

from ...utils import needs_py310


@pytest.fixture(
    name="client",
    params=[
        "tutorial002_py39",
        pytest.param("tutorial002_py310", marks=needs_py310),
        "tutorial002_an_py39",
        pytest.param("tutorial002_an_py310", marks=needs_py310),
    ],
)
def get_client(request: pytest.FixtureRequest):
    mod = importlib.import_module(f"docs_src.background_tasks.{request.param}")

    client = TestClient(mod.app)
    return client


def test(client: TestClient):
    log = Path("log.txt")
    if log.is_file():
        os.remove(log)  # pragma: no cover
    response = client.post("/send-notification/foo@example.com?q=some-query")
    assert response.status_code == 200, response.text
    assert response.json() == {"message": "Message sent"}
    with open("./log.txt") as f:
        assert "found query: some-query\nmessage to foo@example.com" in f.read()

Domain

Subdomains

Functions

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, Applications subdomain.
What functions are defined in test_tutorial002.py?
test_tutorial002.py defines 2 function(s): get_client, test.
What does test_tutorial002.py depend on?
test_tutorial002.py imports 6 module(s): importlib, os, pathlib, pytest, testclient.py, utils.
Where is test_tutorial002.py in the architecture?
test_tutorial002.py is located at tests/test_tutorial/test_background_tasks/test_tutorial002.py (domain: FastAPI, subdomain: Applications, directory: tests/test_tutorial/test_background_tasks).

Analyze Your Own Codebase

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

Try Supermodel Free