"""Тесты Prometheus-метрик сервиса (src/metrics.py).""" from __future__ import annotations from src import metrics def test_start_metrics_server_uses_given_port(mocker) -> None: """start_metrics_server передаёт порт в prometheus_client.start_http_server.""" start_mock = mocker.patch("src.metrics.start_http_server") metrics.start_metrics_server(9100) start_mock.assert_called_once_with(9100) def test_metric_names_exposed_in_registry() -> None: """Счётчики зарегистрированы с ожидаемыми именами (с суффиксом _total).""" from prometheus_client import REGISTRY names = { sample.name for metric in REGISTRY.collect() for sample in metric.samples } for name in ( "etl_rows_processed_total", "etl_chunks_upserted_total", "etl_files_processed_total", "etl_files_failed_total", ): assert name in names