Files
clickstream-ch-kafka-supers…/generator/tests/conftest.py
T
ddadminandDmitry Dementiev ffe81167c3 refactor(generator): удалён in-memory fallback для истории батчей
- Удалён класс InMemoryBatchHistory и вся fallback-логика
- Упрощён KafkaBatchHistory: убраны _initialized, get_stats(), обработка ошибок
- Обновлена документация (generator/README.md, docs/OPERATIONS.md)
- Упрощены тесты, удалены тесты для удалённого функционала
- Код стал честнее: без Kafka генератор падает при старте

Ревьюер: Prometheus даёт достаточно visibility, fallback избыточен
2026-06-09 17:27:16 +03:00

58 lines
1.5 KiB
Python

"""
Pytest fixtures для тестирования генератора.
"""
import sys
from pathlib import Path
# Добавляем родительскую директорию в путь
sys.path.insert(0, str(Path(__file__).parent.parent))
import pytest
from generator import Config, EventDictionary
@pytest.fixture
def data_dir():
"""Путь к директории с тестовыми данными."""
return Path(__file__).parent.parent.parent / "data"
@pytest.fixture
def event_dictionary(data_dir):
"""Загруженный словарь событий."""
return EventDictionary.load(data_dir)
@pytest.fixture
def base_config(data_dir):
"""Базовая конфигурация для тестов."""
return Config(
kafka_bootstrap_servers="localhost:9092",
tick_seconds=5,
lambda_base_per_min=200,
jitter_pct=20,
min_events_per_tick=5,
max_events_per_tick=50,
data_dir=data_dir,
seed=42,
enabled=True,
metrics_port=9109,
)
@pytest.fixture
def config_no_jitter(base_config):
"""Конфигурация без jitter."""
from dataclasses import replace
return replace(base_config, jitter_pct=0)
@pytest.fixture
def empty_temp_dir(tmp_path):
"""Временная директория с пустыми JSONL файлами."""
for fname in ["browser_events.jsonl", "location_events.jsonl",
"device_events.jsonl", "geo_events.jsonl"]:
(tmp_path / fname).touch()
return tmp_path