Skip to content

Commit

Permalink
fix: Use inclusive minimum in Overdraft schema (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonagestam authored Aug 26, 2023
1 parent 31d356e commit 7511220
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/immoney/_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def schema(currency_schema: core_schema.CoreSchema) -> core_schema.CoreSchema:
wrapped=core_schema.typed_dict_schema(
{
"overdraft_subunits": core_schema.typed_dict_field(
core_schema.int_schema(gt=0),
core_schema.int_schema(ge=0),
required=True,
),
"currency": core_schema.typed_dict_field(
Expand Down
12 changes: 6 additions & 6 deletions tests/test_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,14 @@ def test_can_roundtrip_valid_data(
assert instance.overdraft == expected
assert json.loads(instance.model_dump_json()) == data

@pytest.mark.parametrize("value", (0, -1, -1024))
def test_parsing_raises_validation_error_for_non_positive_value(
@pytest.mark.parametrize("value", (-1, -1024))
def test_parsing_raises_validation_error_for_negative_value(
self,
value: int,
) -> None:
with pytest.raises(
ValidationError,
match=r"Input should be greater than 0",
match=r"Input should be greater than or equal to 0",
):
DefaultOverdraftModel.model_validate(
{
Expand Down Expand Up @@ -736,7 +736,7 @@ def test_can_generate_schema(self) -> None:
"overdraft_subunits": {
"title": "Overdraft Subunits",
"type": "integer",
"exclusiveMinimum": 0,
"minimum": 0,
},
},
"required": sorted_items_equal(["overdraft_subunits", "currency"]),
Expand Down Expand Up @@ -806,7 +806,7 @@ def test_can_generate_schema(self) -> None:
"overdraft_subunits": {
"title": "Overdraft Subunits",
"type": "integer",
"exclusiveMinimum": 0,
"minimum": 0,
},
},
"required": sorted_items_equal(["overdraft_subunits", "currency"]),
Expand Down Expand Up @@ -872,7 +872,7 @@ def test_can_generate_schema(self) -> None:
"overdraft_subunits": {
"title": "Overdraft Subunits",
"type": "integer",
"exclusiveMinimum": 0,
"minimum": 0,
},
},
"required": sorted_items_equal(["overdraft_subunits", "currency"]),
Expand Down

0 comments on commit 7511220

Please sign in to comment.