def test_get_pod_usage(monkeypatch, fake_pod_metric_responses): mock_client = get_mock_client(fake_pod_metric_responses) cluster = Cluster("test-cluster-1", "test-cluster-1", "https://test-cluster-1.example.org", mock_client) pods = {('default', 'pod-1'): {'usage': new_resources()}} get_pod_usage(cluster, pods) assert pods[('default', 'pod-1')]['usage']['cpu'] == 0.05
def test_get_pod_usage(monkeypatch, fake_metric_responses): monkeypatch.setattr( "kube_resource_report.report.request", lambda cluster, path: MagicMock(json=lambda: fake_metric_responses.get( path)), ) pods = {('default', 'pod-1'): {'usage': new_resources()}} get_pod_usage(None, pods) assert pods[('default', 'pod-1')]['usage']['cpu'] == 0.05
def test_get_pod_usage(monkeypatch, fake_pod_metric_responses): mock_client = get_mock_client(fake_pod_metric_responses) cluster = Cluster( "test-cluster-1", "test-cluster-1", "https://test-cluster-1.example.org", mock_client, ) pods = {("default", "pod-1"): {"usage": new_resources()}} get_pod_usage(cluster, pods, {}, 1.0) assert pods[("default", "pod-1")]["usage"]["cpu"] == 0.05