diff --git a/tad/api/deps.py b/tad/api/deps.py index a29bb2068..9dd182150 100644 --- a/tad/api/deps.py +++ b/tad/api/deps.py @@ -2,13 +2,14 @@ from fastapi.templating import Jinja2Templates from jinja2 import Environment -from tad.core.config import get_settings +from tad.core.config import VERSION def version_context_processor(request: Request): - return {"version": get_settings().VERSION} + return {"version": VERSION} + env = Environment( autoescape=True, ) -templates = Jinja2Templates(directory="tad/site/templates/",context_processors=[version_context_processor], env=env) +templates = Jinja2Templates(directory="tad/site/templates/", context_processors=[version_context_processor], env=env) diff --git a/tests/conftest.py b/tests/conftest.py index 9010f53a3..8673b0976 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,11 +17,12 @@ from tests.database_test_utils import DatabaseTestUtils +def run_uvicorn(uvicorn: Any) -> None: + uvicorn_run(app, host=uvicorn["host"], port=uvicorn["port"]) + + @pytest.fixture(scope="module") def run_server(request: pytest.FixtureRequest) -> Generator[Any, None, None]: - def run_uvicorn(uvicorn: Any) -> None: - uvicorn_run(app, host=uvicorn["host"], port=uvicorn["port"]) - uvicorn_settings = request.config.uvicorn # type: ignore process = Process(target=run_uvicorn, args=(uvicorn_settings,)) # type: ignore @@ -42,7 +43,7 @@ def pytest_configure(config: pytest.Config) -> None: os.environ["APP_DATABASE_SCHEME"] = "sqlite" config.uvicorn = { # type: ignore - "host": "localhost", + "host": "127.0.0.1", "port": 8756, } @@ -79,9 +80,9 @@ def browser( context = browser.new_context(base_url=run_server) page = context.new_page() - transport = httpx.HTTPTransport(retries=5) + transport = httpx.HTTPTransport(retries=5, local_address="127.0.0.1") with httpx.Client(transport=transport, verify=False) as client: # noqa: S501 - client.get(f"{run_server}/", timeout=0.3) + client.get(f"{run_server}/", timeout=0.8) yield page browser.close() diff --git a/tests/database_test_utils.py b/tests/database_test_utils.py index 37a22b99a..4fbdc4c24 100644 --- a/tests/database_test_utils.py +++ b/tests/database_test_utils.py @@ -11,9 +11,8 @@ def __init__(self, session: Session) -> None: self.models: list[BaseModel] = [] def __del__(self): - for model in self.models: - self.session.delete(model) - self.session.commit() + SQLModel.metadata.drop_all(get_engine()) + SQLModel.metadata.create_all(get_engine()) def given(self, models: list[BaseModel]) -> None: self.models.extend(models)