Coverage for tests / test_tutorial / test_relationship_attributes / test_delete_records_relationship / test_tutorial001.py: 100%
13 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-11-09 00:02 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-11-09 00:02 +0000
1import importlib 1abcdefghi
2from types import ModuleType 1abcdefghi
4import pytest 1abcdefghi
5from sqlalchemy import Engine 1abcdefghi
7from ....conftest import PrintMock 1abcdefghi
10@pytest.fixture( 1abcdefghi
11 name="mod",
12 params=[
13 pytest.param("tutorial001_py310"),
14 ],
15)
16def get_module(request: pytest.FixtureRequest, database_engine: Engine) -> ModuleType: 1abcdefghi
17 mod = importlib.import_module( 1abcdefghi
18 f"docs_src.tutorial.relationship_attributes.cascade_delete_relationships.{request.param}"
19 )
20 mod.engine = database_engine 1abcdefghi
21 return mod 1abcdefghi
24def test_tutorial(print_mock: PrintMock, mod: ModuleType): 1abcdefghi
25 mod.main() 1jklmnopqr
26 assert print_mock.calls == [ 1jklmnopqr
27 [
28 "Created hero:",
29 {
30 "name": "Deadpond",
31 "secret_name": "Dive Wilson",
32 "team_id": 1,
33 "id": 1,
34 "age": None,
35 },
36 ],
37 [
38 "Created hero:",
39 {
40 "name": "Rusty-Man",
41 "secret_name": "Tommy Sharp",
42 "team_id": 2,
43 "id": 2,
44 "age": 48,
45 },
46 ],
47 [
48 "Created hero:",
49 {
50 "name": "Spider-Boy",
51 "secret_name": "Pedro Parqueador",
52 "team_id": None,
53 "id": 3,
54 "age": None,
55 },
56 ],
57 [
58 "Updated hero:",
59 {
60 "name": "Spider-Boy",
61 "secret_name": "Pedro Parqueador",
62 "team_id": 2,
63 "id": 3,
64 "age": None,
65 },
66 ],
67 [
68 "Team Wakaland:",
69 {"name": "Wakaland", "id": 3, "headquarters": "Wakaland Capital City"},
70 ],
71 [
72 "Deleted team:",
73 {"name": "Wakaland", "id": 3, "headquarters": "Wakaland Capital City"},
74 ],
75 ["Black Lion not found:", None],
76 ["Princess Sure-E not found:", None],
77 ]