Skip to content

Commit a91d06d

Browse files
committed
added test
1 parent ac6bc20 commit a91d06d

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

sds_data_manager/lambda_code/IAlirtCode/ialirt_db_query_api.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ def process_item_types(item: dict) -> dict:
3131
# Vectors fields
3232
if isinstance(value, list):
3333
result[key] = [int(v) if v % 1 == 0 else round(float(v), 3) for v in value]
34-
# Dictionary with number
35-
elif isinstance(value, dict) and "N" in value:
36-
num = Decimal(value["N"])
37-
result[key] = int(num) if num % 1 == 0 else round(float(num), 3)
38-
# Dictionary with boolean
39-
elif isinstance(value, dict) and "BOOL" in value:
40-
result[key] = bool(value["BOOL"])
34+
# Dictionary fields
35+
elif isinstance(value, dict):
36+
nested = {}
37+
for k, v in value.items():
38+
if isinstance(v, Decimal):
39+
nested[k] = int(v) if v % 1 == 0 else round(float(v), 3)
40+
else:
41+
nested[k] = v
42+
result[key] = nested
4143
# Scalar fields
4244
elif isinstance(value, Decimal):
4345
result[key] = int(value) if value % 1 == 0 else round(float(value), 3)

tests/lambda_endpoints/test_ialirt_db_query_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ def test_process_item_types():
261261
"mag_B_GSE": [Decimal("0.0"), Decimal("0.1"), Decimal("0.2")],
262262
"mag_B_magnitude": Decimal("0.22"),
263263
"met_in_utc": "2025-06-20T08:00:00", # string should stay unchanged
264+
"mag_hk_status": {"pri_isvalid": True, "hkn8v5": Decimal("3680")},
264265
}
265266
]
266267

@@ -274,5 +275,6 @@ def test_process_item_types():
274275
"mag_B_GSE": [0.0, 0.1, 0.2],
275276
"mag_B_magnitude": 0.22,
276277
"met_in_utc": "2025-06-20T08:00:00",
278+
"mag_hk_status": {"pri_isvalid": True, "hkn8v5": 3680},
277279
}
278280
]

0 commit comments

Comments
 (0)