Files
javadandCursor b93ecf1691 Initial commit of the Kamidso API.
Keep source, config, and deploy files. Leave runtime data, uploads, and logs out of git.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-10 13:43:09 +03:30

20 lines
629 B
Python

import json
import math
from kamidso.api.responses import SafeJSONResponse
from kamidso.jsonutil import json_safe
def test_json_safe_replaces_non_finite_floats():
cleaned = json_safe(
{"manager_id": float("nan"), "amounts": [float("inf"), 1.5], "name": "جواد"}
)
assert cleaned == {"manager_id": None, "amounts": [None, 1.5], "name": "جواد"}
json.dumps(cleaned, allow_nan=False)
def test_safe_json_response_renders_nan_as_null():
response = SafeJSONResponse({"rows": [{"manager_id": math.nan}]})
payload = json.loads(response.body)
assert payload["rows"][0]["manager_id"] is None