Skip to content

Commit

Permalink
remove unused var
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-koziol-iteo authored and mtyton committed Feb 2, 2024
1 parent be5b841 commit abb0d34
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions audoma/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions audoma/tests/test_openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
)
Expand All @@ -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 = {
Expand Down

0 comments on commit abb0d34

Please sign in to comment.