Skip to content

Commit b886da2

Browse files
committed
Update tests for integer Decimal serialization
Update test expectations to match the new behavior where whole number Decimal values are serialized as integers instead of floats. This aligns with the change to _json_serializer that preserves integer types for version numbers and other integer values.
1 parent 2e17ab3 commit b886da2

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

.dockerignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
node_modules
22
.venv
33
.ijwb
4-
.idea
4+
.idea
5+
temp
6+
csaf_analysis
7+
bazel-*
8+
.git
9+
container_data

apollo/tests/test_admin_routes_supported_products.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ def test_json_serializer_decimal_integer(self):
168168
"""Test JSON serializer with integer Decimal."""
169169
decimal_val = Decimal("42")
170170
result = _json_serializer(decimal_val)
171-
self.assertEqual(result, 42.0)
172-
self.assertIsInstance(result, float)
171+
self.assertEqual(result, 42)
172+
self.assertIsInstance(result, int)
173173

174174
def test_json_serializer_unsupported_type(self):
175175
"""Test JSON serializer with unsupported type."""
@@ -211,10 +211,11 @@ def test_format_export_data_with_decimal(self):
211211

212212
result = _format_export_data(data)
213213

214-
# Should be valid JSON with Decimals converted to floats
214+
# Should be valid JSON with Decimals converted appropriately
215+
# (floats for decimals, ints for whole numbers)
215216
parsed = json.loads(result)
216217
self.assertEqual(parsed[0]["price"], 19.99)
217-
self.assertEqual(parsed[1]["price"], 99.0)
218+
self.assertEqual(parsed[1]["price"], 99)
218219

219220
def test_format_export_data_empty(self):
220221
"""Test formatting empty export data."""

0 commit comments

Comments
 (0)