Coverage for tests/test_tutorial/test_relationship_attributes/test_create_and_update_relationships/test_tutorial001_py39.py: 100%
14 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 1jefghi
3from sqlmodel import create_engine 1jefghi
5from ....conftest import get_testing_print_function, needs_py39 1jefghi
7expected_calls = [ 1efghi
8 [
9 "Created hero:",
10 {
11 "age": None,
12 "id": 1,
13 "secret_name": "Dive Wilson",
14 "team_id": 1,
15 "name": "Deadpond",
16 },
17 ],
18 [
19 "Created hero:",
20 {
21 "age": 48,
22 "id": 2,
23 "secret_name": "Tommy Sharp",
24 "team_id": 2,
25 "name": "Rusty-Man",
26 },
27 ],
28 [
29 "Created hero:",
30 {
31 "age": None,
32 "id": 3,
33 "secret_name": "Pedro Parqueador",
34 "team_id": None,
35 "name": "Spider-Boy",
36 },
37 ],
38 [
39 "Updated hero:",
40 {
41 "age": None,
42 "id": 3,
43 "secret_name": "Pedro Parqueador",
44 "team_id": 2,
45 "name": "Spider-Boy",
46 },
47 ],
48 [
49 "Team Wakaland:",
50 {"id": 3, "headquarters": "Wakaland Capital City", "name": "Wakaland"},
51 ],
52 [
53 "Preventers new hero:",
54 {
55 "age": 32,
56 "id": 6,
57 "secret_name": "Natalia Roman-on",
58 "team_id": 2,
59 "name": "Tarantula",
60 },
61 ],
62 [
63 "Preventers new hero:",
64 {
65 "age": 36,
66 "id": 7,
67 "secret_name": "Steve Weird",
68 "team_id": 2,
69 "name": "Dr. Weird",
70 },
71 ],
72 [
73 "Preventers new hero:",
74 {
75 "age": 93,
76 "id": 8,
77 "secret_name": "Esteban Rogelios",
78 "team_id": 2,
79 "name": "Captain North America",
80 },
81 ],
82]
85@needs_py39 1jefghi
86def test_tutorial(clear_sqlmodel): 1efghi
87 from docs_src.tutorial.relationship_attributes.create_and_update_relationships import ( 1abcd
88 tutorial001_py39 as mod,
89 )
91 mod.sqlite_url = "sqlite://" 1abcd
92 mod.engine = create_engine(mod.sqlite_url) 1abcd
93 calls = [] 1abcd
95 new_print = get_testing_print_function(calls) 1abcd
97 with patch("builtins.print", new=new_print): 1abcd
98 mod.main() 1abcd
99 assert calls == expected_calls 1abcd