Coverage for tests/test_tutorial/test_insert/test_tutorial003_py310.py: 100%

26 statements  

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

1from sqlmodel import Session, create_engine, select 1idefgh

2 

3from ...conftest import needs_py310 1idefgh

4 

5 

6@needs_py310 1idefgh

7def test_tutorial(clear_sqlmodel): 1defgh

8 from docs_src.tutorial.insert import tutorial003_py310 as mod 1abc

9 

10 mod.sqlite_url = "sqlite://" 1abc

11 mod.engine = create_engine(mod.sqlite_url) 1abc

12 mod.main() 1abc

13 with Session(mod.engine) as session: 1abc

14 heroes = session.exec(select(mod.Hero)).all() 1abc

15 heroes_by_name = {hero.name: hero for hero in heroes} 1abc

16 deadpond = heroes_by_name["Deadpond"] 1abc

17 spider_boy = heroes_by_name["Spider-Boy"] 1abc

18 rusty_man = heroes_by_name["Rusty-Man"] 1abc

19 assert deadpond.name == "Deadpond" 1abc

20 assert deadpond.age is None 1abc

21 assert deadpond.id is not None 1abc

22 assert deadpond.secret_name == "Dive Wilson" 1abc

23 assert spider_boy.name == "Spider-Boy" 1abc

24 assert spider_boy.age is None 1abc

25 assert spider_boy.id is not None 1abc

26 assert spider_boy.secret_name == "Pedro Parqueador" 1abc

27 assert rusty_man.name == "Rusty-Man" 1abc

28 assert rusty_man.age == 48 1abc

29 assert rusty_man.id is not None 1abc

30 assert rusty_man.secret_name == "Tommy Sharp" 1abc