From 7a14992223b0b278c8621717b549306ce196e408 Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Mon, 12 Jun 2017 12:30:25 -0400 Subject: [PATCH 1/2] Add a test case to test for duplicate balance sheet entries. --- .../test_financials/test_cash_balance.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/bpfin/tests/test_financials/test_cash_balance.py b/bpfin/tests/test_financials/test_cash_balance.py index 880f499..27527b4 100644 --- a/bpfin/tests/test_financials/test_cash_balance.py +++ b/bpfin/tests/test_financials/test_cash_balance.py @@ -1,8 +1,11 @@ -from bpfin.financials.cash_balance import cash_balance +"""Test the cash balance file.""" from datetime import date +import pytest +from bpfin.financials.cash_balance import cash_balance def test_cash_balance_year_gap(): + """Test cash_balance function when year 2016 has balance sheet entry for true and false.""" input_dictionary = { date(2014, 11, 1): (500, False), date(2014, 12, 1): (400, False), @@ -26,6 +29,8 @@ def test_cash_balance_year_gap(): def test_cash_balance(): + """Test cash_balance function when one record is bank statement for that year, one is from balance sheet and other + has 3 from bank statement.""" input_dictionary = { date(2014, 11, 1): (500, False), date(2015, 12, 31): (600, True), @@ -51,5 +56,17 @@ def test_cash_balance(): 2016: 400.0 } result = cash_balance(input_analysis_date, input_dictionary) - assert result == output_cash_balance + +def test_cash_balance_3(): + """Test cash_balance when same year has 2 balance sheet entries. Should raise a ValueError.""" + input_dictionary = { + date(2014, 11, 1): (500, True), + date(2015, 11, 11): (300, True), + } + analysis_date = { + 'proforma_start': date(2012, 1, 1), + 'proforma_duration': 20, + } + with pytest.raises(ValueError): + cash_balance(analysis_date, input_dictionary) -- GitLab From d4ec91035c2c73a56d4df61e7fae11d1e0d4e5ee Mon Sep 17 00:00:00 2001 From: Adarsh Murthy Date: Mon, 12 Jun 2017 14:11:39 -0400 Subject: [PATCH 2/2] Change one of the inputs. --- bpfin/tests/test_financials/test_cash_balance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bpfin/tests/test_financials/test_cash_balance.py b/bpfin/tests/test_financials/test_cash_balance.py index 27527b4..bab44ed 100644 --- a/bpfin/tests/test_financials/test_cash_balance.py +++ b/bpfin/tests/test_financials/test_cash_balance.py @@ -62,7 +62,7 @@ def test_cash_balance_3(): """Test cash_balance when same year has 2 balance sheet entries. Should raise a ValueError.""" input_dictionary = { date(2014, 11, 1): (500, True), - date(2015, 11, 11): (300, True), + date(2014, 11, 11): (300, True), } analysis_date = { 'proforma_start': date(2012, 1, 1), -- GitLab