✅ Add tests
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
from typing import Any, Dict, List, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
from sqlmodel import create_engine
|
||||
from sqlmodel.pool import StaticPool
|
||||
|
||||
from ....conftest import get_testing_print_function
|
||||
|
||||
expected_calls = [
|
||||
[
|
||||
"Created hero:",
|
||||
{
|
||||
"age": None,
|
||||
"id": 1,
|
||||
"secret_name": "Dive Wilson",
|
||||
"team_id": 2,
|
||||
"name": "Deadpond",
|
||||
},
|
||||
],
|
||||
[
|
||||
"Created hero:",
|
||||
{
|
||||
"age": 48,
|
||||
"id": 2,
|
||||
"secret_name": "Tommy Sharp",
|
||||
"team_id": 1,
|
||||
"name": "Rusty-Man",
|
||||
},
|
||||
],
|
||||
[
|
||||
"Created hero:",
|
||||
{
|
||||
"age": None,
|
||||
"id": 3,
|
||||
"secret_name": "Pedro Parqueador",
|
||||
"team_id": None,
|
||||
"name": "Spider-Boy",
|
||||
},
|
||||
],
|
||||
]
|
||||
|
||||
|
||||
def test_tutorial001(clear_sqlmodel):
|
||||
from docs_src.tutorial.connect.insert import tutorial001 as mod
|
||||
|
||||
mod.sqlite_url = "sqlite://"
|
||||
mod.engine = create_engine(mod.sqlite_url)
|
||||
calls = []
|
||||
|
||||
new_print = get_testing_print_function(calls)
|
||||
|
||||
with patch("builtins.print", new=new_print):
|
||||
mod.main()
|
||||
assert calls == expected_calls
|
||||
Reference in New Issue
Block a user