def test_available_lenders_returns_all_available_loaners(self): market_info = [self.lender_a, self.lender_b, self.lender_c] market = Market(market_info=market_info) lenders = market.available_lenders(loan_amount=2000) self.assertEquals(len(lenders), 2) self.assertIn(self.lender_b, lenders) self.assertIn(self.lender_c, lenders)
def _setup_market_2_calculator(self): lender_a = Lender('Lender A', '0.07', '1000') lender_b = Lender('Lender B', '0.1', '5000') lender_c = Lender('Lender C', '0.08', '10000') market_info = [lender_a, lender_b, lender_c] market = Market(market_info=market_info) return Calculator(market=market)
def main(market_file, loan_amount): file_data = [r for r in csv.DictReader(market_file)] market_info = _lowercase_file_headernames(file_data) market = Market(market_info=market_info) calculator = Calculator(market=market) try: quote = calculator.get_quote(int(loan_amount)) except ValueError as e: print('Loan not possible, reason: {}'.format(e)) else: print('Requested amount: £{0}'.format(loan_amount)) print('Rate: {0}'.format(quote.pretty_rate)) print('Monthly repayment: £{0}'.format(quote.monthly_repayment)) print('Total repayment: £{0}'.format(quote.total_repayment)) return quote
def _setup_market_1_calculator(self): lender_a = Lender('Lender A', '0.07', '10000') market = Market(market_info=[lender_a]) return Calculator(market=market)
def test_available_lenders_raises_when_no_available_loan_amount(self): market = Market(market_info=[self.lender_a]) self.assertRaises(ValueError, market.available_lenders, 2000)
def test_available_lenders_raises_when_no_lenders_in_market(self): market = Market() self.assertEquals(market.number_of_lenders, 0) self.assertRaises(ValueError, market.available_lenders, 1000)
def test_market_lenders_are_stored(self): market_info = [self.lender_a, self.lender_b, self.lender_c] market = Market(market_info=market_info) self.assertEquals(len(market.lenders), len(market_info)) self.assertEquals(market_info, market.lenders) self.assertEquals(self.lender_a, market['Lender A'])