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 47d559e commit 81d640c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest

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

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

settings = SimpleStrategySettings()
strategy = SimpleStrategy(settings)

with patch(
"robusta_krr.core.integrations.prometheus.loader.PrometheusMetricsLoader.gather_data",
new=AsyncMock(
return_value={
metric: {pod.name: metric_points_data for pod in TEST_OBJECT.pods} for metric in SimpleStrategy.metrics
metric.__name__: {pod.name: metric_points_data for pod in TEST_OBJECT.pods}
for metric in strategy.metrics
},
),
) as mock_prometheus_loader:
Expand Down

0 comments on commit 81d640c

Please sign in to comment.