Skip to content

Commit 1865901

Browse files
authored
Merge pull request #181 from ecmwf-projects/fix-costing
handle max_cost_value of str type
2 parents 32dca18 + 2fcada7 commit 1865901

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

cads_processing_api_service/costing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def compute_costing(
5252
max_costs: dict[str, Any] = costing_config.get("max_costs", {})
5353
max_costs_exceeded = {}
5454
for max_cost_id, max_cost_value in max_costs.items():
55+
max_cost_value = float(max_cost_value)
5556
if max_cost_id in costs.keys():
5657
if costs[max_cost_id] > max_cost_value:
5758
max_costs_exceeded[max_cost_id] = max_cost_value

tests/test_30_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import datetime
1818
import unittest.mock
19+
import uuid
1920
from typing import Any
2021

2122
import cacholote
@@ -211,8 +212,11 @@ def test_make_pagination_query_params() -> None:
211212

212213

213214
def test_dictify_job() -> None:
214-
request = cads_broker.database.SystemRequest(request_id=0, status="failed")
215-
exp_job = {"request_id": 0, "status": "failed"}
215+
request_uid = uuid.uuid4()
216+
request = cads_broker.database.SystemRequest(
217+
request_uid=request_uid, status="failed"
218+
)
219+
exp_job = {"request_uid": request_uid, "status": "failed"}
216220
res_job = utils.dictify_job(request)
217221
assert isinstance(res_job, dict)
218222
assert all([key in res_job and res_job[key] == exp_job[key] for key in exp_job])

0 commit comments

Comments
 (0)