kin/tests/conftest.py

28 lines
1.2 KiB
Python
Raw Normal View History

"""Shared pytest fixtures for Kin test suite."""
import pytest
from unittest.mock import patch
@pytest.fixture(autouse=True)
def _set_kin_secret_key(monkeypatch):
"""Set KIN_SECRET_KEY for all tests (required by _encrypt_auth/_decrypt_auth)."""
from cryptography.fernet import Fernet
monkeypatch.setenv("KIN_SECRET_KEY", Fernet.generate_key().decode())
@pytest.fixture(autouse=True)
def _mock_check_claude_auth():
"""Авто-мок agents.runner.check_claude_auth для всех тестов.
run_pipeline() вызывает check_claude_auth() перед запуском агентов.
Без мока тесты, использующие side_effect-очереди для subprocess.run,
ломаются: первый вызов (auth-check) потребляет элемент очереди.
Тесты TestCheckClaudeAuth (test_runner.py) НЕ затрагиваются:
они вызывают check_claude_auth через напрямую импортированную ссылку
(bound at module load time), а не через agents.runner.check_claude_auth.
"""
with patch("agents.runner.check_claude_auth"):
yield