Coverage for tests/test_tutorial/test_insert/test_tutorial002.py: 100%
24 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 sqlmodel import Session, create_engine, select 1ghijkl
4def test_tutorial(clear_sqlmodel): 1ghijkl
5 from docs_src.tutorial.insert import tutorial002 as mod 1abcdef
7 mod.sqlite_url = "sqlite://" 1abcdef
8 mod.engine = create_engine(mod.sqlite_url) 1abcdef
9 mod.main() 1abcdef
10 with Session(mod.engine) as session: 1abcdef
11 heroes = session.exec(select(mod.Hero)).all() 1abcdef
12 heroes_by_name = {hero.name: hero for hero in heroes} 1abcdef
13 deadpond = heroes_by_name["Deadpond"] 1abcdef
14 spider_boy = heroes_by_name["Spider-Boy"] 1abcdef
15 rusty_man = heroes_by_name["Rusty-Man"] 1abcdef
16 assert deadpond.name == "Deadpond" 1abcdef
17 assert deadpond.age is None 1abcdef
18 assert deadpond.id is not None 1abcdef
19 assert deadpond.secret_name == "Dive Wilson" 1abcdef
20 assert spider_boy.name == "Spider-Boy" 1abcdef
21 assert spider_boy.age is None 1abcdef
22 assert spider_boy.id is not None 1abcdef
23 assert spider_boy.secret_name == "Pedro Parqueador" 1abcdef
24 assert rusty_man.name == "Rusty-Man" 1abcdef
25 assert rusty_man.age == 48 1abcdef
26 assert rusty_man.id is not None 1abcdef
27 assert rusty_man.secret_name == "Tommy Sharp" 1abcdef