@@ -58,14 +58,14 @@ def test_run_with_emissions_online(speedy_heartbeat, mock_co2_signal, create_pla
58
58
run_created , _ = create_plain_run
59
59
metric_interval = 1
60
60
run_created ._user_config .eco .co2_signal_api_token = "test_token"
61
+ current_count = run_created .metric_spy .call_count
61
62
run_created .config (enable_emission_metrics = True , system_metrics_interval = metric_interval )
62
- spy = mocker .spy (run_created , "_get_internal_metrics" )
63
63
while (
64
64
"sustainability.emissions.total" not in requests .get (
65
65
url = f"{ run_created ._user_config .server .url } /metrics/names" ,
66
66
headers = run_created ._headers ,
67
67
params = {"runs" : json .dumps ([run_created .id ])}).json ()
68
- and spy .call_count < 4
68
+ and run_created . metric_spy .call_count < 4
69
69
):
70
70
time .sleep (metric_interval )
71
71
_run = RunObject (identifier = run_created .id )
@@ -85,7 +85,7 @@ def test_run_with_emissions_online(speedy_heartbeat, mock_co2_signal, create_pla
85
85
# Check that total = previous total + latest delta
86
86
_total_values = _metric_values [_total_metric_name ].tolist ()
87
87
_delta_values = _metric_values [_delta_metric_name ].tolist ()
88
- assert len (_total_values ) == spy . call_count
88
+ assert len (_total_values ) >= run_created . metric_spy . call_count - current_count
89
89
for i in range (1 , len (_total_values )):
90
90
assert _total_values [i ] == _total_values [i - 1 ] + _delta_values [i ]
91
91
0 commit comments