-
-
Notifications
You must be signed in to change notification settings - Fork 832
Expand file tree
/
Copy pathtest_tutorial001.py
More file actions
94 lines (86 loc) · 1.86 KB
/
test_tutorial001.py
File metadata and controls
94 lines (86 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from unittest.mock import patch
from sqlmodel import create_engine
from ...conftest import get_testing_print_function
expected_calls = [
[
"Created villain:",
{
"name": "Thinnus",
"power_level": 9001,
"id": 1,
"boss_id": None,
},
],
[
"Created villain:",
{
"name": "Ebonite Mew",
"power_level": 400,
"id": 3,
"boss_id": 1,
},
],
[
"Created villain:",
{
"name": "Dark Shorty",
"power_level": 200,
"id": 4,
"boss_id": 1,
},
],
[
"Created villain:",
{
"name": "Ultra Bot",
"power_level": 2**9,
"id": 2,
"boss_id": None,
},
],
[
"Updated villain:",
{
"name": "Ultra Bot",
"power_level": 2**9,
"id": 2,
"boss_id": 1,
},
],
[
"Added minion:",
{
"name": "Clone Bot 1",
"power_level": 2**6,
"id": 5,
"boss_id": 2,
},
],
[
"Added minion:",
{
"name": "Clone Bot 2",
"power_level": 2**6,
"id": 6,
"boss_id": 2,
},
],
[
"Added minion:",
{
"name": "Clone Bot 3",
"power_level": 2**6,
"id": 7,
"boss_id": 2,
},
],
]
def test_tutorial(clear_sqlmodel):
from docs_src.advanced.self_referential import tutorial001 as mod
mod.sqlite_url = "sqlite://"
mod.engine = create_engine(mod.sqlite_url)
calls = []
new_print = get_testing_print_function(calls)
with patch("builtins.print", new=new_print):
mod.main()
assert calls == expected_calls