Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
desconto precisa ser uma data do futuro! (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigondec authored Sep 30, 2020
1 parent 665eb8d commit 349b624
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion imopay_wrapper/models/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class DiscountConfiguration(FineConfiguration):
date: str

def _validate_date(self):
validate_date_isoformat(self, "date", past=True, allow_today=True)
validate_date_isoformat(self, "date", future=True, allow_today=True)


@dataclass
Expand Down
11 changes: 6 additions & 5 deletions tests/models/transaction/test_configuration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unittest import TestCase
from unittest.mock import MagicMock, patch

from ...utils import today, yesterday
from ...utils import yesterday, today, tomorrow
from imopay_wrapper.models.transaction import (
BaseConfiguration,
InterestConfiguration,
Expand Down Expand Up @@ -204,7 +204,7 @@ def test_validate_date_1(self):
Então:
- N/A
"""
valid_values = [today(), yesterday()]
valid_values = [today(), tomorrow()]

instance = MagicMock()

Expand All @@ -220,9 +220,9 @@ def test_validate_date_2(self):
- um mapeamento invalid_values_by_error de vários erros para
listas de valores inválidos
{
FieldError: ['-1', 0],
TypeError: [[], None, {}],
ValueError: ['a']
FieldError: [yesterday()],
ValueError: ["-1", "a"],
TypeError: [0, {}, [], None],
}
- uma instância qualquer
Quando:
Expand All @@ -232,6 +232,7 @@ def test_validate_date_2(self):
- deve ser lançado o erro específico para cada valor
"""
invalid_values_by_error = {
FieldError: [yesterday()],
ValueError: ["-1", "a"],
TypeError: [0, {}, [], None],
}
Expand Down
2 changes: 1 addition & 1 deletion tests/models/transaction/test_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_init_nested_fields_1(self):
{
"value": 1,
"charge_type": BaseConfiguration.FIXED,
"date": "2020-08-28",
"date": today(),
}
],
}
Expand Down
3 changes: 2 additions & 1 deletion tests/models/transaction/test_invoice_configurations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest import TestCase

from ...utils import today
from imopay_wrapper.models.transaction import InvoiceConfigurations, BaseConfiguration


Expand All @@ -23,7 +24,7 @@ def test_3(self):
{
"value": 1,
"charge_type": BaseConfiguration.FIXED,
"date": "2020-08-28",
"date": today(),
}
]
}
Expand Down

0 comments on commit 349b624

Please sign in to comment.