summaryrefslogtreecommitdiff
path: root/finance/test_income.py
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-09-03 21:34:08 +0200
committerxengineering <me@xengineering.eu>2024-09-08 17:21:32 +0200
commit4f3d4de3796744ee1d6d0e91e8bec76e0487de90 (patch)
tree2bf795e09fa051c66916011657dea31cfb1d8338 /finance/test_income.py
parentb0b34adbd86fc778923a766273c145cc657918cd (diff)
downloadfinance-py-4f3d4de3796744ee1d6d0e91e8bec76e0487de90.tar
finance-py-4f3d4de3796744ee1d6d0e91e8bec76e0487de90.tar.zst
finance-py-4f3d4de3796744ee1d6d0e91e8bec76e0487de90.zip
finance: Use datetime for Income.integrate()
Time-based Integration in general is done between two time stamps. For the financial context it makes sense to use Python's datetime.datetime class for this purpose. This commit implements integrating an income between two datetime.datetime time stamps.
Diffstat (limited to 'finance/test_income.py')
-rw-r--r--finance/test_income.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/finance/test_income.py b/finance/test_income.py
index 21d42f7..0ce3507 100644
--- a/finance/test_income.py
+++ b/finance/test_income.py
@@ -1,6 +1,17 @@
+from datetime import datetime
+
from finance import income
def test_income_integration() -> None:
inc = income.Income(amount=3000.0)
- assert inc.integrate(5) == 15000.0
+
+ tests = (
+ (datetime(2024, 3, 12), datetime(2024, 4, 2), 3000.0),
+ (datetime(2024, 3, 1), datetime(2024, 3, 15), 3000.0),
+ (datetime(2024, 2, 25), datetime(2024, 3, 1), 3000.0),
+ (datetime(2024, 2, 25), datetime(2024, 6, 12), 12000.0),
+ )
+
+ for test in tests:
+ assert inc.integrate(start=test[0], end=test[1]) == test[2]