Files
2026-06-13 08:23:21 -03:00

38 lines
1.2 KiB
Python

"""
Pytest configuration and fixtures for all tests.
"""
# Stub google.cloud.pubsub_v1 BEFORE any other import. `agent_framework`
# (private TIM package) instantiates a PublisherClient at import time,
# which requires GCloud creds; tests run without those.
import sys as _sys
from unittest.mock import MagicMock as _MagicMock
_sys.modules.setdefault("google.cloud.pubsub_v1", _MagicMock())
# Load .env BEFORE any other import so that Settings fields that call
# os.environ[] at class-definition time (e.g. TAIS_DB_DSN) are satisfied.
from dotenv import load_dotenv
load_dotenv()
import os
import pytest
@pytest.fixture(scope="session", autouse=True)
def setup_test_environment():
"""
Set up environment variables for testing.
This fixture runs once per test session and sets required
environment variables to allow config module to load.
"""
# Set required environment variables for Settings
os.environ.setdefault("LLM_PROVIDER", "openai")
os.environ.setdefault("LLM_MODEL", "gpt-4")
os.environ.setdefault("LOG_LEVEL", "INFO")
os.environ.setdefault("LOG_FORMAT", "text")
yield
# Cleanup is not needed as these are just defaults