Coverage for tests/test_tutorial/test_relationship_attributes/test_delete_records_relationship/test_tutorial002.py: 100%
12 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 00:02 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 00:02 +0000
1from unittest.mock import patch 1ghijkl
3from sqlmodel import create_engine 1ghijkl
5from ....conftest import get_testing_print_function 1ghijkl
8def test_tutorial(clear_sqlmodel): 1ghijkl
9 from docs_src.tutorial.relationship_attributes.cascade_delete_relationships import ( 1abcdef
10 tutorial002 as mod,
11 )
13 mod.sqlite_url = "sqlite://" 1abcdef
14 mod.engine = create_engine(mod.sqlite_url) 1abcdef
15 calls = [] 1abcdef
17 new_print = get_testing_print_function(calls) 1abcdef
19 with patch("builtins.print", new=new_print): 1abcdef
20 mod.main() 1abcdef
21 assert calls == [ 1abcdef
22 [
23 "Created hero:",
24 {
25 "age": None,
26 "id": 1,
27 "name": "Deadpond",
28 "secret_name": "Dive Wilson",
29 "team_id": 1,
30 },
31 ],
32 [
33 "Created hero:",
34 {
35 "age": 48,
36 "id": 2,
37 "name": "Rusty-Man",
38 "secret_name": "Tommy Sharp",
39 "team_id": 2,
40 },
41 ],
42 [
43 "Created hero:",
44 {
45 "age": None,
46 "id": 3,
47 "name": "Spider-Boy",
48 "secret_name": "Pedro Parqueador",
49 "team_id": None,
50 },
51 ],
52 [
53 "Updated hero:",
54 {
55 "age": None,
56 "id": 3,
57 "name": "Spider-Boy",
58 "secret_name": "Pedro Parqueador",
59 "team_id": 2,
60 },
61 ],
62 [
63 "Team Wakaland:",
64 {"headquarters": "Wakaland Capital City", "id": 3, "name": "Wakaland"},
65 ],
66 [
67 "Deleted team:",
68 {"headquarters": "Wakaland Capital City", "id": 3, "name": "Wakaland"},
69 ],
70 [
71 "Black Lion has no team:",
72 {
73 "age": 35,
74 "id": 4,
75 "name": "Black Lion",
76 "secret_name": "Trevor Challa",
77 "team_id": None,
78 },
79 ],
80 [
81 "Princess Sure-E has no team:",
82 {
83 "age": None,
84 "id": 5,
85 "name": "Princess Sure-E",
86 "secret_name": "Sure-E",
87 "team_id": None,
88 },
89 ],
90 ]