Something went wrong. Try again.
Add sqlite capabilities to wheke with sqlmodel
Something went wrong. Try again.
1.1 kB · 42 lines
Python
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243from collections.abc import Generatorfrom pathlib import Path
import pytestfrom fastapi.testclient import TestClientfrom typer.testing import CliRunnerfrom wheke import WhekeSettings
from wheke_sqlmodel import SQLITE_DRIVER, SQLModelSettings
from .example_app import build_wheke
@pytest.fixturedef settings(tmp_path: Path) -> WhekeSettings: sqlmodel_settings = SQLModelSettings( connection_string=f"{SQLITE_DRIVER}:///{tmp_path / 'test.db'}", echo_operations=True, ) return WhekeSettings( features={ sqlmodel_settings.__feature_name__: sqlmodel_settings.model_dump(), } )
@pytest.fixturedef client(settings: WhekeSettings) -> Generator[TestClient]: wheke = build_wheke(settings) runner = CliRunner() cli = wheke.create_cli()
# setup result = runner.invoke(cli, ["sqlmodel", "create-db"]) assert result.exit_code == 0
with TestClient(build_wheke(settings).create_app()) as client: yield client
# teardown result = runner.invoke(cli, ["sqlmodel", "drop-db"]) assert result.exit_code == 0