diff --git a/audoma/examples.py b/audoma/examples.py index a70ea48..c22585c 100644 --- a/audoma/examples.py +++ b/audoma/examples.py @@ -50,9 +50,8 @@ def generate_value(self) -> float: """ min_val = float(getattr(self.field, "min_value", 1) or 1) max_val = float(getattr(self.field, "max_value", 1000) or 1000) - max_digits = getattr(self.field, "max_digits", None) decimal_places = getattr(self.field, "decimal_places", None) - if max_digits and decimal_places: + if decimal_places: fmt = f".{decimal_places}f" return Decimal(f"{(max_val):{fmt}}") ret = random.uniform(min_val, max_val) diff --git a/audoma/tests/test_openapi.py b/audoma/tests/test_openapi.py index 4e7fc2f..c1c68a0 100644 --- a/audoma/tests/test_openapi.py +++ b/audoma/tests/test_openapi.py @@ -357,7 +357,11 @@ def test_map_serializer_field_choicefield_xchoices_success(self): ) def test_decimal_examples_are_generated_correctly(self): - fields_config = {"order_value": audoma_fields.DecimalField(max_digits=5, decimal_places=2, min_value=999.98, max_value=999.99)} + fields_config = { + "order_value": audoma_fields.DecimalField( + max_digits=5, decimal_places=2, min_value=999.98, max_value=999.99 + ) + } serializer = create_serializer( fields_config=fields_config, serializer_base_classes=[Serializer] ) @@ -371,7 +375,7 @@ def test_decimal_examples_are_generated_correctly(self): mapped_field = view.schema._map_serializer_field( serializer_fields["order_value"], direction="response" ) - self.assertEqual(mapped_field['example'], '999.99') + self.assertEqual(mapped_field["example"], "999.99") def test_map_serializer_field_audoma_choicefield_xchoices_success(self): fields_config = {