✅ Add tests
This commit is contained in:
0
tests/test_tutorial/test_where/__init__.py
Normal file
0
tests/test_tutorial/test_where/__init__.py
Normal file
28
tests/test_tutorial/test_where/test_tutorial001.py
Normal file
28
tests/test_tutorial/test_where/test_tutorial001.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from typing import Any, Dict, List, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
from ...conftest import get_testing_print_function
|
||||
|
||||
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.where 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 == [
|
||||
[
|
||||
{
|
||||
"name": "Deadpond",
|
||||
"secret_name": "Dive Wilson",
|
||||
"age": None,
|
||||
"id": 1,
|
||||
}
|
||||
]
|
||||
]
|
||||
29
tests/test_tutorial/test_where/test_tutorial002.py
Normal file
29
tests/test_tutorial/test_where/test_tutorial002.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from typing import Any, Dict, List, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
from ...conftest import get_testing_print_function
|
||||
|
||||
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.where import tutorial002 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": "Spider-Boy",
|
||||
"secret_name": "Pedro Parqueador",
|
||||
"age": None,
|
||||
"id": 2,
|
||||
}
|
||||
],
|
||||
[{"name": "Rusty-Man", "secret_name": "Tommy Sharp", "age": 48, "id": 3}],
|
||||
]
|
||||
31
tests/test_tutorial/test_where/test_tutorial003.py
Normal file
31
tests/test_tutorial/test_where/test_tutorial003.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from typing import Any, Dict, List, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
from ...conftest import get_testing_print_function
|
||||
|
||||
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.where import tutorial003 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 == [
|
||||
[{"id": 6, "name": "Dr. Weird", "secret_name": "Steve Weird", "age": 36}],
|
||||
[{"id": 3, "name": "Rusty-Man", "secret_name": "Tommy Sharp", "age": 48}],
|
||||
[
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Captain North America",
|
||||
"secret_name": "Esteban Rogelios",
|
||||
"age": 93,
|
||||
}
|
||||
],
|
||||
]
|
||||
31
tests/test_tutorial/test_where/test_tutorial004.py
Normal file
31
tests/test_tutorial/test_where/test_tutorial004.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from typing import Any, Dict, List, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
from ...conftest import get_testing_print_function
|
||||
|
||||
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.where import tutorial004 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 == [
|
||||
[{"id": 5, "name": "Black Lion", "secret_name": "Trevor Challa", "age": 35}],
|
||||
[{"id": 6, "name": "Dr. Weird", "secret_name": "Steve Weird", "age": 36}],
|
||||
[{"id": 3, "name": "Rusty-Man", "secret_name": "Tommy Sharp", "age": 48}],
|
||||
[
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Captain North America",
|
||||
"secret_name": "Esteban Rogelios",
|
||||
"age": 93,
|
||||
}
|
||||
],
|
||||
]
|
||||
21
tests/test_tutorial/test_where/test_tutorial005.py
Normal file
21
tests/test_tutorial/test_where/test_tutorial005.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from typing import Any, Dict, List, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
from ...conftest import get_testing_print_function
|
||||
|
||||
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.where import tutorial005 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": "Tarantula", "secret_name": "Natalia Roman-on", "age": 32, "id": 4}]
|
||||
]
|
||||
22
tests/test_tutorial/test_where/test_tutorial006.py
Normal file
22
tests/test_tutorial/test_where/test_tutorial006.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from typing import Any, Dict, List, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
from ...conftest import get_testing_print_function
|
||||
|
||||
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.where import tutorial006 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": "Tarantula", "secret_name": "Natalia Roman-on", "age": 32, "id": 4}],
|
||||
[{"name": "Black Lion", "secret_name": "Trevor Challa", "age": 35, "id": 5}],
|
||||
]
|
||||
22
tests/test_tutorial/test_where/test_tutorial007.py
Normal file
22
tests/test_tutorial/test_where/test_tutorial007.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from typing import Any, Dict, List, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
from ...conftest import get_testing_print_function
|
||||
|
||||
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.where import tutorial007 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 == [
|
||||
[{"id": 5, "name": "Black Lion", "secret_name": "Trevor Challa", "age": 35}],
|
||||
[{"id": 6, "name": "Dr. Weird", "secret_name": "Steve Weird", "age": 36}],
|
||||
]
|
||||
22
tests/test_tutorial/test_where/test_tutorial008.py
Normal file
22
tests/test_tutorial/test_where/test_tutorial008.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from typing import Any, Dict, List, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
from ...conftest import get_testing_print_function
|
||||
|
||||
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.where import tutorial008 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 == [
|
||||
[{"id": 5, "name": "Black Lion", "secret_name": "Trevor Challa", "age": 35}],
|
||||
[{"id": 6, "name": "Dr. Weird", "secret_name": "Steve Weird", "age": 36}],
|
||||
]
|
||||
30
tests/test_tutorial/test_where/test_tutorial009.py
Normal file
30
tests/test_tutorial/test_where/test_tutorial009.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from typing import Any, Dict, List, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
from ...conftest import get_testing_print_function
|
||||
|
||||
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.where import tutorial009 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": "Tarantula", "secret_name": "Natalia Roman-on", "age": 32, "id": 4}],
|
||||
[{"name": "Black Lion", "secret_name": "Trevor Challa", "age": 35, "id": 5}],
|
||||
[
|
||||
{
|
||||
"name": "Captain North America",
|
||||
"secret_name": "Esteban Rogelios",
|
||||
"age": 93,
|
||||
"id": 7,
|
||||
}
|
||||
],
|
||||
]
|
||||
30
tests/test_tutorial/test_where/test_tutorial010.py
Normal file
30
tests/test_tutorial/test_where/test_tutorial010.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from typing import Any, Dict, List, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
from ...conftest import get_testing_print_function
|
||||
|
||||
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.where import tutorial010 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": "Tarantula", "secret_name": "Natalia Roman-on", "age": 32, "id": 4}],
|
||||
[{"name": "Black Lion", "secret_name": "Trevor Challa", "age": 35, "id": 5}],
|
||||
[
|
||||
{
|
||||
"name": "Captain North America",
|
||||
"secret_name": "Esteban Rogelios",
|
||||
"age": 93,
|
||||
"id": 7,
|
||||
}
|
||||
],
|
||||
]
|
||||
31
tests/test_tutorial/test_where/test_tutorial011.py
Normal file
31
tests/test_tutorial/test_where/test_tutorial011.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from typing import Any, Dict, List, Union
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlmodel import create_engine
|
||||
from ...conftest import get_testing_print_function
|
||||
|
||||
|
||||
def test_tutorial(clear_sqlmodel):
|
||||
from docs_src.tutorial.where import tutorial011 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 == [
|
||||
[{"id": 5, "name": "Black Lion", "secret_name": "Trevor Challa", "age": 35}],
|
||||
[{"id": 6, "name": "Dr. Weird", "secret_name": "Steve Weird", "age": 36}],
|
||||
[{"id": 3, "name": "Rusty-Man", "secret_name": "Tommy Sharp", "age": 48}],
|
||||
[
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Captain North America",
|
||||
"secret_name": "Esteban Rogelios",
|
||||
"age": 93,
|
||||
}
|
||||
],
|
||||
]
|
||||
Reference in New Issue
Block a user