Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaveMyYard committed Aug 2, 2023
1 parent 288c8de commit 5d37d7e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

from robusta_krr.api.models import K8sObjectData, PodData, ResourceAllocations
from robusta_krr.strategies import SimpleStrategy

TEST_OBJECT = K8sObjectData(
cluster="mock-cluster",
Expand Down Expand Up @@ -57,9 +58,11 @@ def mock_prometheus_loader():
metric_points_data = np.array([(t, random.randrange(0, 100)) for t in np.linspace(start_ts, now_ts, 3600)])

with patch(
"robusta_krr.core.integrations.prometheus.loader.MetricsLoader.gather_data",
"robusta_krr.core.integrations.prometheus.loader.PrometheusMetricsLoader.gather_data",
new=AsyncMock(
return_value={pod.name: metric_points_data for pod in TEST_OBJECT.pods},
return_value={
metric: {pod.name: metric_points_data for pod in TEST_OBJECT.pods} for metric in SimpleStrategy.metrics
},
),
) as mock_prometheus_loader:
mock_prometheus_loader
Expand All @@ -68,5 +71,5 @@ def mock_prometheus_loader():

@pytest.fixture(autouse=True, scope="session")
def mock_prometheus_init():
with patch("robusta_krr.core.integrations.prometheus.loader.MetricsLoader.__init__", return_value=None):
with patch("robusta_krr.core.integrations.prometheus.loader.PrometheusMetricsLoader.__init__", return_value=None):
yield

0 comments on commit 5d37d7e

Please sign in to comment.