AI-Sprint-bot / tests /conftest.py
FreshPixels's picture
Create tests/conftest.py
7595c34 verified
Raw
History Blame Contribute Delete
1.22 kB
from __future__ import annotations
import os
import pytest
from core.config.settings import get_settings
@pytest.fixture(autouse=True)
def _reset_settings_cache():
"""Reset the lru_cache on get_settings() before each test.
This ensures that each test gets a fresh Settings instance
based on the environment variables active at that point.
"""
get_settings.cache_clear()
yield
get_settings.cache_clear()
@pytest.fixture
def env_bot_token():
"""Provide a valid test bot token in the environment."""
os.environ["BOT_TOKEN"] = "123456789:AAHdqTcvCH1vGWJxfSeofSAsQK6PALsAWo"
yield
os.environ.pop("BOT_TOKEN", None)
@pytest.fixture
def env_admin_id():
"""Provide a valid test admin ID in the environment."""
os.environ["ADMIN_ID"] = "123456789"
yield
os.environ.pop("ADMIN_ID", None)
@pytest.fixture
def env_openai_key():
"""Provide a dummy OpenAI API key in the environment."""
os.environ["OPENAI_API_KEY"] = "sk-test-key-for-unit-tests"
yield
os.environ.pop("OPENAI_API_KEY", None)
@pytest.fixture
def env_full(env_bot_token, env_admin_id, env_openai_key):
"""Set all required environment variables for tests."""
pass