Coverage for tests/test_tutorial/test_select/test_tutorial003_py310_tutorial004_py310.py: 100%

26 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-09 00:02 +0000

1from typing import Any, Dict, List, Union 1labcde

2from unittest.mock import patch 1labcde

3 

4from sqlmodel import create_engine 1labcde

5 

6from ...conftest import get_testing_print_function, needs_py310 1labcde

7 

8 

9def check_calls(calls: List[List[Union[str, Dict[str, Any]]]]): 1labcde

10 assert calls[0][0] == [ 1fghijk

11 { 

12 "name": "Deadpond", 

13 "secret_name": "Dive Wilson", 

14 "age": None, 

15 "id": 1, 

16 }, 

17 { 

18 "name": "Spider-Boy", 

19 "secret_name": "Pedro Parqueador", 

20 "age": None, 

21 "id": 2, 

22 }, 

23 { 

24 "name": "Rusty-Man", 

25 "secret_name": "Tommy Sharp", 

26 "age": 48, 

27 "id": 3, 

28 }, 

29 ] 

30 

31 

32@needs_py310 1labcde

33def test_tutorial_003(clear_sqlmodel): 1abcde

34 from docs_src.tutorial.select import tutorial003_py310 as mod 1gik

35 

36 mod.sqlite_url = "sqlite://" 1gik

37 mod.engine = create_engine(mod.sqlite_url) 1gik

38 calls = [] 1gik

39 

40 new_print = get_testing_print_function(calls) 1gik

41 

42 with patch("builtins.print", new=new_print): 1gik

43 mod.main() 1gik

44 check_calls(calls) 1gik

45 

46 

47@needs_py310 1labcde

48def test_tutorial_002(clear_sqlmodel): 1abcde

49 from docs_src.tutorial.select import tutorial004_py310 as mod 1fhj

50 

51 mod.sqlite_url = "sqlite://" 1fhj

52 mod.engine = create_engine(mod.sqlite_url) 1fhj

53 calls = [] 1fhj

54 

55 new_print = get_testing_print_function(calls) 1fhj

56 

57 with patch("builtins.print", new=new_print): 1fhj

58 mod.main() 1fhj

59 check_calls(calls) 1fhj