This commit is contained in:
Waylon Walker 2023-05-19 14:11:01 -05:00
parent 4be274d9e2
commit c238b9d757
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4
21 changed files with 219 additions and 184 deletions

25
tests/test_hero.py Normal file
View file

@ -0,0 +1,25 @@
import tempfile
import pytest
from sqlmodel import Session
from learn_sql_model.config import Config, get_config
from learn_sql_model.factories.hero import HeroFactory
from learn_sql_model.models.hero import Hero
Hero
@pytest.fixture
def config() -> Session:
tmp_db = tempfile.NamedTemporaryFile(suffix=".db")
config = get_config({"database_url": f"sqlite:///{tmp_db.name}"})
config.create_db_and_tables()
return config
def test_post_hero(config: Config) -> None:
hero = HeroFactory().build(name="Batman", age=50)
hero.post(config=config)
assert hero.get(hero.id) == hero
breakpoint()