def test_coin_part_revision_3(self): part1 = CoinPart() self.assertIsNotNone(part1) self.assertIs(CoinPartFlag.NONE, part1.flags) self.assertTrue(part1.balance == 0) part1.deposit(100) self.assertEqual(100, part1.balance) part1.withdraw(100) self.assertEqual(0, part1.balance) # wrong value self.assertRaises(InvalidParamsException, part1.deposit, -10) # 0 transfer is possible old = part1.balance part1.deposit(0) self.assertEqual(old, part1.balance) self.assertRaises(InvalidParamsException, part1.withdraw, -11234) self.assertRaises(OutOfBalanceException, part1.withdraw, 1) old = part1.balance part1.withdraw(0) self.assertEqual(old, part1.balance)
def test_coin_part_withdraw(self): balance = 100 part = CoinPart() self.assertFalse(part.is_dirty()) part.deposit(balance) part.withdraw(balance) self.assertTrue(part.is_dirty()) self.assertEqual(0, part.balance)