summaryrefslogtreecommitdiff
path: root/finance/test_flow.py
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-09-08 17:02:33 +0200
committerxengineering <me@xengineering.eu>2024-09-08 17:21:32 +0200
commit458a24d09f95eefb161728d9676ecdfca30e3f5e (patch)
treed3260b2531f42a6e8335661312661302b9653730 /finance/test_flow.py
parent6973093a2b80b4fb9e216d1b3e329dd4c2badc7c (diff)
downloadfinance-py-458a24d09f95eefb161728d9676ecdfca30e3f5e.tar
finance-py-458a24d09f95eefb161728d9676ecdfca30e3f5e.tar.zst
finance-py-458a24d09f95eefb161728d9676ecdfca30e3f5e.zip
Split flow.py to simulate.py and model.py
model.py should be a file containing only dataclasses to model finance. simulate.py should take care of the simulation of that finance data to create a financial forecast.
Diffstat (limited to 'finance/test_flow.py')
-rw-r--r--finance/test_flow.py47
1 files changed, 0 insertions, 47 deletions
diff --git a/finance/test_flow.py b/finance/test_flow.py
deleted file mode 100644
index 91d189b..0000000
--- a/finance/test_flow.py
+++ /dev/null
@@ -1,47 +0,0 @@
-from datetime import datetime
-from decimal import Decimal
-
-from finance.flow import Flow, simulate
-
-
-def test_flow_integration() -> None:
- fl = Flow(
- amount=Decimal(3000.0),
- since=datetime(2023, 1, 1),
- until=datetime(2026, 1, 5),
- )
-
- tests = (
- (datetime(2024, 3, 12), datetime(2024, 4, 2), Decimal(3000.0)),
- (datetime(2024, 3, 1), datetime(2024, 3, 15), Decimal(3000.0)),
- (datetime(2024, 2, 25), datetime(2024, 3, 1), Decimal(3000.0)),
- (datetime(2024, 2, 25), datetime(2024, 6, 12), Decimal(12000.0)),
- (datetime(2022, 1, 5), datetime(2022, 9, 14), Decimal(0.0)),
- (datetime(2022, 1, 5), datetime(2023, 1, 1), Decimal(3000.0)),
- (datetime(2022, 7, 4), datetime(2024, 12, 8), Decimal(72000.0)),
- (datetime(2025, 11, 4), datetime(2026, 5, 9), Decimal(6000.0)),
- (datetime(2026, 1, 5), datetime(2027, 1, 1), Decimal(0.0)),
- (datetime(2027, 5, 28), datetime(2028, 7, 7), Decimal(0.0)),
- )
-
- for test in tests:
- assert fl.integrate(start=test[0], end=test[1]) == test[2]
-
-
-def test_simulate() -> None:
- flows = (Flow(amount=Decimal(100.0), since=None, until=None),)
-
- simulated = simulate(
- start=datetime(2024, 1, 1),
- end=datetime(2024, 4, 1),
- flows=flows,
- )
-
- expected = [
- (datetime(2024, 1, 1), Decimal(100.0)),
- (datetime(2024, 2, 1), Decimal(200.0)),
- (datetime(2024, 3, 1), Decimal(300.0)),
- (datetime(2024, 4, 1), Decimal(400.0)),
- ]
-
- assert simulated == expected