Skip to content

Commit

Permalink
WIP improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fcayre committed Oct 25, 2023
1 parent b2c8e7c commit 61c1591
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions rental_fees/tests/test_rental_fees_computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,22 @@ def months_from_start(date):
delta = relativedelta(date, start_date)
return delta.years * 12 + delta.months

def fees_descr(details):
mfs = months_from_start # just a short alias
aday = relativedelta(days=1)
return [(mfs(d.from_date), mfs(d.to_date + aday), d.fees) for d in details]

forecast_fees = computation.detail_ids.filtered("is_forecast")
actual_fees = computation.detail_ids - forecast_fees

self.assertEqual(
[
(months_from_start(d.from_date), months_from_start(d.to_date))
for d in computation.detail_ids
],
[(0, 2), (2, 3), (3, 5), (5, 39)],
fees_descr(actual_fees),
[(0, 1, 2.50), (1, 2, 2.50), (2, 3, 12.50), (3, 4, 12.50)],
)

self.assertEqual(
[d.fees for d in computation.detail_ids], [0.0, 0.0, 45.0, 52.5]
fees_descr(forecast_fees),
[],
)

self.assertEqual(
Expand Down

0 comments on commit 61c1591

Please sign in to comment.