mirror of
https://github.com/fastapi/sqlmodel.git
synced 2026-01-05 17:09:42 -06:00
📝 Add source examples for Python 3.9 and 3.10 (#715)
* 📝 Add source examples for Python 3.9 and 3.10 * ✅ Add tests for new source examples for Python 3.9 and 3.10, still needs pytest markers * ✅ Add tests for fastapi examples * ✅ Update tests for FastAPI app testing, for Python 3.9 and 3.10, fixing multi-app testing conflicts * ✅ Require Python 3.9 and 3.10 for tests * ✅ Update tests with missing markers
This commit is contained in:
committed by
GitHub
parent
cce30d7546
commit
d8effcbc5c
@@ -0,0 +1,35 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
|
||||
from ...conftest import get_testing_print_function, needs_py310
|
||||
|
||||
expected_calls = [
|
||||
[
|
||||
[
|
||||
{"id": 1, "name": "Deadpond", "secret_name": "Dive Wilson", "age": None},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Spider-Boy",
|
||||
"secret_name": "Pedro Parqueador",
|
||||
"age": None,
|
||||
},
|
||||
{"id": 3, "name": "Rusty-Man", "secret_name": "Tommy Sharp", "age": 48},
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
@needs_py310
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.offset_and_limit import tutorial001_py310 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
|
||||
@@ -0,0 +1,35 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
|
||||
from ...conftest import get_testing_print_function, needs_py310
|
||||
|
||||
expected_calls = [
|
||||
[
|
||||
[
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Tarantula",
|
||||
"secret_name": "Natalia Roman-on",
|
||||
"age": 32,
|
||||
},
|
||||
{"id": 5, "name": "Black Lion", "secret_name": "Trevor Challa", "age": 35},
|
||||
{"id": 6, "name": "Dr. Weird", "secret_name": "Steve Weird", "age": 36},
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
@needs_py310
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.offset_and_limit import tutorial002_py310 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
|
||||
@@ -0,0 +1,33 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
|
||||
from ...conftest import get_testing_print_function, needs_py310
|
||||
|
||||
expected_calls = [
|
||||
[
|
||||
[
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Captain North America",
|
||||
"secret_name": "Esteban Rogelios",
|
||||
"age": 93,
|
||||
}
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
@needs_py310
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.offset_and_limit import tutorial003_py310 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
|
||||
@@ -0,0 +1,27 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
|
||||
from ...conftest import get_testing_print_function, needs_py310
|
||||
|
||||
|
||||
@needs_py310
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.offset_and_limit import tutorial004_py310 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 == [
|
||||
[
|
||||
[
|
||||
{"name": "Dr. Weird", "secret_name": "Steve Weird", "age": 36, "id": 6},
|
||||
{"name": "Rusty-Man", "secret_name": "Tommy Sharp", "age": 48, "id": 3},
|
||||
]
|
||||
]
|
||||
]
|
||||
Reference in New Issue
Block a user