30 lines
852 B
Python
30 lines
852 B
Python
"""Integration tests configuration."""
|
|
|
|
import os
|
|
from typing import Iterator
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
def set_test_environment() -> Iterator[None]:
|
|
"""Set environment to development for all integration tests."""
|
|
original_env = os.environ.get("ENVIRONMENT")
|
|
os.environ["ENVIRONMENT"] = "development"
|
|
yield
|
|
# Cleanup: restore original environment
|
|
if original_env is None:
|
|
os.environ.pop("ENVIRONMENT", None)
|
|
else:
|
|
os.environ["ENVIRONMENT"] = original_env
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def app_test_client() -> Iterator[TestClient]:
|
|
"""Provides a TestClient for the FastAPI app."""
|
|
# Import here after environment is set
|
|
from baby_monitor.main import app
|
|
|
|
with TestClient(app) as client:
|
|
yield client
|