def test_get_net_worth(self): investor = Investor(18., init_cash=10., income=2., shares=0.) self.assertEqual(investor.get_net_worth(20.), 10.) investor.get_paid() self.assertEqual(investor.get_net_worth(20.), 12.) investor.shares = 5. self.assertEqual(investor.get_net_worth(20.), 112.)
def test_sell_all(self): investor = Investor(18., init_cash=10., shares=0.) investor.sell_all(20.) self.assertEqual(investor.cash, investor.init_cash) self.assertEqual(investor.shares, 0.) investor.shares = 5. investor.sell_all(20.) self.assertEqual(investor.cash, 110.) self.assertEqual(investor.shares, 0.)