def test_revision_to_fees(self): revision = RentRevision(start_date=date(2011, 4, 1), rent=200, provision=100) self.assertEqual([], revision_to_cashflows(revision, date(2011, 4, 1)), "no fees before") self.assertEqual([(date(2011, 4, 1), -200), (date(2011, 4, 1), -100)], map(cashflow_to_tuple, revision_to_cashflows(revision, date(2011, 5, 1)))) self.assertEqual( 6, len(revision_to_cashflows(revision, date(2011, 7, 1))), "following fees")
def test_revision_to_fees(self): revision = RentRevision( start_date=date(2011, 4, 1), rent=200, provision=100) self.assertEqual( [], revision_to_cashflows(revision, date(2011, 4, 1)), "no fees before") self.assertEqual( [(date(2011, 4, 1), -200), (date(2011, 4, 1), -100)], map(cashflow_to_tuple, revision_to_cashflows( revision, date(2011, 5, 1)))) self.assertEqual( 6, len(revision_to_cashflows(revision, date(2011, 7, 1))), "following fees")
def test_revision_to_fees(self): revision = RentRevision( start_date=date(2011, 4, 1), rent=200, provision=100) rentRevision_partial = RentRevision( start_date=date(2010, 11, 26), end_date=date(2011, 1, 25), rent=200.0, provision=100.0)# 591,935483871 fee self.assertEqual( [], revision_to_cashflows(revision, date(2011, 3, 31)), "no fees before") self.assertEqual( [(date(2011, 4, 1), -200), (date(2011, 4, 1), -100)], map(cashflow_to_tuple, revision_to_cashflows( revision, date(2011, 4, 30)))) self.assertEqual( 6, len(revision_to_cashflows(revision, date(2011, 6, 30))), "following fees")
def test_partial_revision_to_fees(self): revision = RentRevision(start_date=date(2010, 10, 1), end_date=date(2010, 11, 16), rent=200, provision=100) result = revision_to_cashflows( revision, # far in future date so that we get all rents date(2015, 4, 1)) self.assertEqual([ (date(2010, 10, 1), -200), (date(2010, 10, 1), -100), (date(2010, 11, 1), -100), (date(2010, 11, 1), -50), ], map(cashflow_to_tuple, result))
def test_partial_revision_to_fees(self): revision = RentRevision( start_date=date(2010, 10, 1), end_date=date(2010, 11, 16), rent=200, provision=100) result = revision_to_cashflows( revision, # far in future date so that we get all rents date(2015, 4, 1)) self.assertEqual([ (date(2010, 10, 1), -200), (date(2010, 10, 1), -100), (date(2010, 11, 1), -100), (date(2010, 11, 1), -50), ], map(cashflow_to_tuple, result))