Skip to content

Commit f419d74

Browse files
committed
Tests: fix tests after refactor
1 parent bf737bf commit f419d74

File tree

5 files changed

+63
-108
lines changed

5 files changed

+63
-108
lines changed

tests/test_tutorial/test_relationship_attributes/test_aliased_relationship/test_tutorial001.py

Lines changed: 0 additions & 80 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from unittest.mock import patch
2+
3+
from sqlmodel import create_engine
4+
5+
from ....conftest import get_testing_print_function
6+
7+
expected_calls = [
8+
[
9+
"Created hero:",
10+
{
11+
"age": None,
12+
"id": 1,
13+
"name": "Deadpond",
14+
"secret_name": "Dive Wilson",
15+
"summer_team_id": 2,
16+
"winter_team_id": 1,
17+
},
18+
],
19+
[
20+
"Created hero:",
21+
{
22+
"age": 48,
23+
"id": 2,
24+
"name": "Rusty-Man",
25+
"secret_name": "Tommy Sharp",
26+
"summer_team_id": 1,
27+
"winter_team_id": 1,
28+
},
29+
],
30+
["Heros with Preventers as their winter team:"],
31+
["Hero: Deadpond, Winter Team: Preventers Summer Team: Z-Force"],
32+
["Hero: Rusty-Man, Winter Team: Preventers Summer Team: Preventers"],
33+
["Heros with Preventers as their winter and Z-Force as their summer team:"],
34+
["Hero: Deadpond, Winter Team: Preventers Summer Team: Z-Force"],
35+
]
36+
37+
38+
def test_tutorial(clear_sqlmodel):
39+
from docs_src.tutorial.relationship_attributes.multiple_relationships_same_model import (
40+
tutorial001 as mod,
41+
)
42+
43+
mod.sqlite_url = "sqlite://"
44+
mod.engine = create_engine(mod.sqlite_url)
45+
calls = []
46+
47+
new_print = get_testing_print_function(calls)
48+
49+
with patch("builtins.print", new=new_print):
50+
mod.main()
51+
assert calls == expected_calls

tests/test_tutorial/test_relationship_attributes/test_aliased_relationship/test_tutorial001_py310.py renamed to tests/test_tutorial/test_relationship_attributes/test_multiple_relationships_same_model/test_tutorial001_py310.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,17 @@
4848
},
4949
],
5050
],
51-
[
52-
"Heros with Preventers as their winter and Z-Force as their summer team:",
53-
[
54-
{
55-
"age": None,
56-
"id": 1,
57-
"name": "Deadpond",
58-
"secret_name": "Dive Wilson",
59-
"summer_team_id": 2,
60-
"winter_team_id": 1,
61-
}
62-
],
63-
],
51+
["Heros with Preventers as their winter team:"],
52+
["Hero: Deadpond, Winter Team: Preventers Summer Team: Z-Force"],
53+
["Hero: Rusty-Man, Winter Team: Preventers Summer Team: Preventers"],
54+
["Heros with Preventers as their winter and Z-Force as their summer team:"],
55+
["Hero: Deadpond, Winter Team: Preventers Summer Team: Z-Force"],
6456
]
6557

6658

6759
@needs_py310
6860
def test_tutorial(clear_sqlmodel):
69-
from docs_src.tutorial.relationship_attributes.aliased_relationship import (
61+
from docs_src.tutorial.relationship_attributes.multiple_relationships_same_model import (
7062
tutorial001_py310 as mod,
7163
)
7264

tests/test_tutorial/test_relationship_attributes/test_aliased_relationship/test_tutorial001_py39.py renamed to tests/test_tutorial/test_relationship_attributes/test_multiple_relationships_same_model/test_tutorial001_py39.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,17 @@
4848
},
4949
],
5050
],
51-
[
52-
"Heros with Preventers as their winter and Z-Force as their summer team:",
53-
[
54-
{
55-
"age": None,
56-
"id": 1,
57-
"name": "Deadpond",
58-
"secret_name": "Dive Wilson",
59-
"summer_team_id": 2,
60-
"winter_team_id": 1,
61-
}
62-
],
63-
],
51+
["Heros with Preventers as their winter team:"],
52+
["Hero: Deadpond, Winter Team: Preventers Summer Team: Z-Force"],
53+
["Hero: Rusty-Man, Winter Team: Preventers Summer Team: Preventers"],
54+
["Heros with Preventers as their winter and Z-Force as their summer team:"],
55+
["Hero: Deadpond, Winter Team: Preventers Summer Team: Z-Force"],
6456
]
6557

6658

6759
@needs_py39
6860
def test_tutorial(clear_sqlmodel):
69-
from docs_src.tutorial.relationship_attributes.aliased_relationship import (
61+
from docs_src.tutorial.relationship_attributes.multiple_relationships_same_model import (
7062
tutorial001_py39 as mod,
7163
)
7264

0 commit comments

Comments
 (0)