Coverage for tests/test_tutorial/test_connect/test_delete/test_tutorial001.py: 100%
13 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 1lghijk
3from sqlmodel import create_engine 1lghijk
5from ....conftest import get_testing_print_function 1lghijk
7expected_calls = [ 1ghijk
8 [
9 "Created hero:",
10 {
11 "age": None,
12 "id": 1,
13 "secret_name": "Dive Wilson",
14 "team_id": 2,
15 "name": "Deadpond",
16 },
17 ],
18 [
19 "Created hero:",
20 {
21 "age": 48,
22 "id": 2,
23 "secret_name": "Tommy Sharp",
24 "team_id": 1,
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": 1,
45 "name": "Spider-Boy",
46 },
47 ],
48 [
49 "No longer Preventer:",
50 {
51 "age": None,
52 "id": 3,
53 "secret_name": "Pedro Parqueador",
54 "team_id": None,
55 "name": "Spider-Boy",
56 },
57 ],
58]
61def test_tutorial(clear_sqlmodel): 1lghijk
62 from docs_src.tutorial.connect.delete import tutorial001 as mod 1abcdef
64 mod.sqlite_url = "sqlite://" 1abcdef
65 mod.engine = create_engine(mod.sqlite_url) 1abcdef
66 calls = [] 1abcdef
68 new_print = get_testing_print_function(calls) 1abcdef
70 with patch("builtins.print", new=new_print): 1abcdef
71 mod.main() 1abcdef
72 assert calls == expected_calls 1abcdef