From ba140253ac140acba61a0caf55791bed179ef297 Mon Sep 17 00:00:00 2001 From: Pavel Zhukov <33721692+LeaveMyYard@users.noreply.github.com> Date: Tue, 26 Mar 2024 13:24:56 +0200 Subject: Improving prometheus detection step (#236) * Rework prometheus detection logging, fix #119 * Fix success if no scans were made * Fix get_history_range in tests * Remove unused constant --------- Co-authored-by: LeaveMyYard --- tests/conftest.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/conftest.py') diff --git a/tests/conftest.py b/tests/conftest.py index 8906c42..61c389d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -94,6 +94,19 @@ def mock_prometheus_load_pods(): yield +@pytest.fixture(autouse=True, scope="session") +def mock_prometheus_get_history_range(): + async def get_history_range(self, history_duration: timedelta) -> tuple[datetime, datetime]: + now = datetime.now() + start = now - history_duration + return start, now + + with patch( + "robusta_krr.core.integrations.prometheus.loader.PrometheusMetricsLoader.get_history_range", get_history_range + ): + yield + + @pytest.fixture(autouse=True, scope="session") def mock_prometheus_init(): with patch("robusta_krr.core.integrations.prometheus.loader.PrometheusMetricsLoader.__init__", return_value=None): -- cgit v1.2.3