def test_add_transaction_after_Stock_Object_creation(self): second_transaction = Transaction("Google", datetime.now(), self.buy,36.23,10) listOfTran = [] listOfTran.append(self.testTran) testObj = Stock("IBM", listOfTran) testObj.add_transactions(second_transaction) self.assertEqual(len(testObj.transactions), 2)
def test_wrong_object_type_added_to_excisting_object(self): tranItem1 = Transaction("Google", datetime.now(), self.buy, 23.32, 20) tranItem2 = "WrongObject" listOfTrans = [] listOfTrans.append(tranItem1) testObj = Stock("Google", listOfTrans) with self.assertRaises(ValueError): testObj.add_transactions(tranItem2)