Coverage for tests/test_tutorial/test_select/test_tutorial001_tutorial002.py: 100%
26 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 typing import Any, Dict, List, Union 1mnopqr
2from unittest.mock import patch 1mnopqr
4from sqlmodel import create_engine 1mnopqr
6from ...conftest import get_testing_print_function 1mnopqr
9def check_calls(calls: List[List[Union[str, Dict[str, Any]]]]): 1mnopqr
10 assert calls[0][0] == { 1abcdefghijkl
11 "name": "Deadpond",
12 "secret_name": "Dive Wilson",
13 "age": None,
14 "id": 1,
15 }
16 assert calls[1][0] == { 1abcdefghijkl
17 "name": "Spider-Boy",
18 "secret_name": "Pedro Parqueador",
19 "age": None,
20 "id": 2,
21 }
22 assert calls[2][0] == { 1abcdefghijkl
23 "name": "Rusty-Man",
24 "secret_name": "Tommy Sharp",
25 "age": 48,
26 "id": 3,
27 }
30def test_tutorial_001(clear_sqlmodel): 1mnopqr
31 from docs_src.tutorial.select import tutorial001 as mod 1acegik
33 mod.sqlite_url = "sqlite://" 1acegik
34 mod.engine = create_engine(mod.sqlite_url) 1acegik
35 calls = [] 1acegik
37 new_print = get_testing_print_function(calls) 1acegik
39 with patch("builtins.print", new=new_print): 1acegik
40 mod.main() 1acegik
41 check_calls(calls) 1acegik
44def test_tutorial_002(clear_sqlmodel): 1mnopqr
45 from docs_src.tutorial.select import tutorial002 as mod 1bdfhjl
47 mod.sqlite_url = "sqlite://" 1bdfhjl
48 mod.engine = create_engine(mod.sqlite_url) 1bdfhjl
49 calls = [] 1bdfhjl
51 new_print = get_testing_print_function(calls) 1bdfhjl
53 with patch("builtins.print", new=new_print): 1bdfhjl
54 mod.main() 1bdfhjl
55 check_calls(calls) 1bdfhjl