当前位置: 首页>>代码示例>>Python>>正文


Python Account.deposit方法代码示例

本文整理汇总了Python中account.Account.deposit方法的典型用法代码示例。如果您正苦于以下问题:Python Account.deposit方法的具体用法?Python Account.deposit怎么用?Python Account.deposit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在account.Account的用法示例。


在下文中一共展示了Account.deposit方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_checking_account

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
def test_checking_account():
    bank = Bank()
    checkingAccount = Account(CHECKING)
    bill = Customer("Bill").openAccount(checkingAccount)
    bank.addCustomer(bill)
    checkingAccount.deposit(100.0)
    assert_equals(bank.totalInterestPaid(), 0.1)
开发者ID:ShiviBector,项目名称:abc-bank-python,代码行数:9,代码来源:bank_tests.py

示例2: test_statement

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
def test_statement():
    checkingAccount = Account(CHECKING)
    savingsAccount = Account(SAVINGS)
    henry = Customer("Henry").openAccount(checkingAccount).openAccount(savingsAccount)
    checkingAccount.deposit(100.0)
    savingsAccount.deposit(4000.0)
    savingsAccount.withdraw(200.0)
    assert_equals(henry.getStatement(),
                  "Statement for Henry" +
                  "\n\nChecking Account\n  deposit $100.00\nTotal $100.00" +
                  "\n\nSavings Account\n  deposit $4000.00\n  withdrawal $200.00\nTotal $3800.00" +
                  "\n\nTotal In All Accounts $3900.00")
开发者ID:malhilli,项目名称:abc-bank-python,代码行数:14,代码来源:customer_tests.py

示例3: TestAccount

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
class TestAccount(unittest.TestCase):
    def setUp(self):
        """Each test should start with a zero-balance account."""
        self.account = Account()
    
    def test_deposit(self):
        """Deposit of n items correctly increases balance."""
        self.account.deposit(1)
        self.assertEqual(self.account.balance, 1)
        
    def test_withdraw_less_than_balance(self):
        """Withdrawal less than balance correctly lowers balance."""
        self.account.deposit(2)
        amount = self.account.withdraw(1)
        self.assertEqual( (amount,self.account.balance), (1,1) )
        
    def test_withdraw_equal_to_balance(self):
        """Withdrawal equal to balance yields balance, sets balance to 0."""
        self.account.deposit(1)
        amount = self.account.withdraw(1)
        self.assertEqual( (amount,self.account.balance), (1,0) )

    def test_withdraw_more_than_balance(self):
        """Withdrawal more than balance yields balance, sets balance to 0."""
        self.account.deposit(1)
        amount = self.account.withdraw(2)
        self.assertEqual( (amount,self.account.balance), (1,0) )
开发者ID:mwulf,项目名称:dreidel_game,代码行数:29,代码来源:test_account.py

示例4: AccountTest

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
class AccountTest(unittest.TestCase):

    def setUp(self):
        self.account = Account(number='123456', holder='Linus')

    def test_it_has_a_number(self):
        self.account.number |should| equal_to('123456')

    def test_it_as_a_holder(self):
        self.account.holder |should| equal_to('Linus')

    def test_it_has_a_balance_beginning_at_zero(self):
        self.account.balance |should| be(0)

    def test_it_allows_deposit(self):
        self.account.deposit(100)
        self.account.balance |should| be(100)
        self.account.deposit(100)
        self.account.balance |should| be(200)

    def test_it_allows_withdrawals(self):
        self.account.deposit(100)
        self.account.withdrawal(75)
        self.account.balance |should| be(25)

    def test_it_raises_an_error_for_insufficient_balance(self):
        self.account.deposit(100)
        (self.account.withdrawal, 100.01) |should| throw(InsufficientBalance)
开发者ID:rodrigomanhaes,项目名称:forkinrio,代码行数:30,代码来源:account_test.py

示例5: main

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
def main():
    """Runs program with account.py and general_functions.py.

    When the program starts, it asks the user for a username and a password. This will be the account the user will use
    for this program. Note: The full user back-end is not programmed yet and so the users info is not used/saved!

    """
    top_menu = "\n\nWelcome to the Banking Simulator!"
    top_spacer = "-" * len(top_menu)
    print("{}\n{}".format(top_menu, top_spacer))
    account = Account()

    while True:
        account.menu_screen()
        cmd = input("> ")

        if cmd == "help":
            menu_help()
        elif cmd == "account":
            account.account_bridge()
        elif cmd == "info":
            account.account_info()
        elif cmd == "deposit":
            account.deposit()
        elif cmd == "withdraw":
            account.withdraw()
        elif cmd == "open account":
            account.open_account()
        elif cmd == "close account":
            account.close_account()
        elif cmd == "save":
            save(account)
        elif cmd == "simulation":
            account.time_simulation()
        elif cmd[0].lower() == "q":
            break
        else:
            print("\nERROR: Input not valid!")
开发者ID:Kwistech,项目名称:BankingSimulator,代码行数:40,代码来源:main.py

示例6: test_maxi_savings_account

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
def test_maxi_savings_account():
    bank = Bank()
    checkingAccount = Account(MAXI_SAVINGS)
    bank.addCustomer(Customer("Bill").openAccount(checkingAccount))
    checkingAccount.deposit(3000.0)
    assert_equals(bank.totalInterestPaid(), 51.0)
开发者ID:ShiviBector,项目名称:abc-bank-python,代码行数:8,代码来源:bank_tests.py

示例7: test_calc_interest

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
 def test_calc_interest(self):
     a = Account()
     a.deposit(100.0)
     assert a.calc_interest() == 0.1
开发者ID:coreyadkins,项目名称:codeguild,代码行数:6,代码来源:account_test.py

示例8: test_withdraw_not_enough

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
 def test_withdraw_not_enough(self):
     a = Account()
     a.deposit(10.0)
     with pytest.raises(ValueError):
         a.withdraw(50.0)
开发者ID:coreyadkins,项目名称:codeguild,代码行数:7,代码来源:account_test.py

示例9: test_withdraw_enough

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
 def test_withdraw_enough(self):
     a = Account()
     a.deposit(100.0)
     a.withdraw(50.0)
     assert a.get_funds() == 50.0
开发者ID:coreyadkins,项目名称:codeguild,代码行数:7,代码来源:account_test.py

示例10: test_check_withdrawal_not_enough

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
 def test_check_withdrawal_not_enough(self):
     a = Account()
     a.deposit(10.0)
     assert not a.check_withdrawal(50.0)
开发者ID:coreyadkins,项目名称:codeguild,代码行数:6,代码来源:account_test.py

示例11: test_deposit_get_funds

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
 def test_deposit_get_funds(self):
     a = Account()
     a.deposit(100.0)
     assert a.get_funds() == 100.0
开发者ID:coreyadkins,项目名称:codeguild,代码行数:6,代码来源:account_test.py

示例12: manager

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
        self.storage = ZODB.DB(None)
        self.connection = self.storage.open()
        self.root = self.connection.root
        self.root.accounts = BTrees.OOBTree.BTree()
        

    def manager(self, accountName, account):
        try:
            self.root.accounts[accountName] = account
            transaction.commit()
        except Exception as e:
            print str(e.message)
            transaction.abort()
            pass
        
    def extract(self, accountName):
        try:
            return self.root.accounts[accountName]
        except (AttributeError, KeyError) as e:
            print "Key Error, %s doesn't exist." % accountName
            exit(-1)
            

if __name__ == "__main__":
    tg = testGenerator()
    a = Account()
    a.deposit(100)
    tg.manager('nello', a)
    
    print tg.extract('nello').balance
开发者ID:shadeimi,项目名称:testLearning,代码行数:32,代码来源:testZODB.py

示例13: transfer_money

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
from account import Account

def transfer_money(a1, a2):
    successful = a1.transferTo(5, a2)

    if successful:
        print('Successful')
    else:
        print('Unsuccessful')

    print("%s has $%d") %(a1.getOwner(), a1.getBalance())
    print("%s has $%d") %(a2.getOwner(), a2.getBalance())

if __name__ == "__main__":
    a1 = Account('Jane')
    a2 = Account('John')

    a1.deposit(100)
    a2.deposit(20)

    transfer_money(a1, a2)

# Reference: http://sydney.edu.au/engineering/it/~jchan3/soft1001/jme/debugging/DebuggingExercise2.java
开发者ID:Egoyibo,项目名称:Debugging-Exercises,代码行数:25,代码来源:exercise2.py

示例14: AccountTest

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import deposit [as 别名]
class AccountTest(unittest.TestCase):

    def setUp(self):
        self.test_account = Account("Peter", 125, "$")

    def test_create_new_account(self):
        self.assertTrue(isinstance(self.test_account, Account))

    def test_create_new_account_without_argumnets(self):
        with self.assertRaises(TypeError):
            Account()

    def test_deposit_int_money_check_balance(self):
        self.test_account.deposit(100)
        self.assertEqual(self.test_account.balance(), 225)

    def test_deposit_float_money_check_balance(self):
        self.test_account.deposit(100.55)
        self.assertEqual(self.test_account.balance(), 225.55)

    def test_deposit_zero_money(self):
        with self.assertRaises(ValueError):
            self.test_account.deposit(0)

    def test_deposit_negative_money(self):
        with self.assertRaises(ValueError):
            self.test_account.deposit(-10)

    def test_deposit_negative_float_money(self):
        with self.assertRaises(ValueError):
            self.test_account.deposit(-10.55)

    def test_witdraw_money_less_than_balance_should_return_true(self):
        self.assertTrue(self.test_account.withdraw(10.5))

    def test_witdraw_money_more_than_balance_should_return_false(self):
        self.assertFalse(self.test_account.withdraw(2000))

    def test_witdraw_money_same_than_balance_should_return_false(self):
        self.assertFalse(
            self.test_account.withdraw(self.test_account.balance()))

    def test_print_account(self):
        self.assertEqual(
            str(self.test_account),
            "Bank account for Peter with balance of 125$")

    def test_int_account(self):
        self.assertEqual(int(self.test_account), 125)

    def test_transfer_money_to_another_account_with_different_currency(self):
        with self.assertRaises(TypeError):
            second_account = Account("Tosho", 100, "BGN")
            self.test_account.transfer_to(second_account, 25)

    def test_transfer_money_to_another_account_with_same_currency(self):
        second_account = Account("Tosho", 100, "$")
        transfer_result = self.test_account.transfer_to(second_account, 25)
        self.assertTrue(transfer_result)

    def test_transfer_more_money_than_balance_to_another_account_with_same_currency(self):
        second_account = Account("Tosho", 100, "$")
        transfer_result = self.test_account.transfer_to(second_account, 2220)
        self.assertFalse(transfer_result)

    def test_account_history_create_account(self):
        the_account = Account("Gogo", 125, "BGN")
        self.assertEqual(the_account.getHistory(), ['Account was created'])

    def test_account_history_deposit_money(self):
        self.test_account.deposit(100)
        self.assertEqual(self.test_account.getHistory(), ['Account was created', 'Deposited 100$'])

    def test_account_history_withdraw_money_should_succes(self):
        self.test_account.withdraw(25)
        self.assertEqual(self.test_account.getHistory(), ['Account was created', '25$ was withdrawed'])

    def test_account_history_withdraw_more_money_than_ballnace_should_failed(self):
        self.test_account.withdraw(225)
        self.assertEqual(self.test_account.getHistory(), ['Account was created', 'Withdraw for 225$ failed.'])

    def test_account_history_balance_check(self):
        self.test_account.balance()
        self.assertEqual(self.test_account.getHistory(), ['Account was created', 'Balance check -> 125$'])

    def test_account_history_int_check(self):
        int(self.test_account)
        self.assertEqual(self.test_account.getHistory(), ['Account was created', '__int__ check -> 125$'])
开发者ID:presian,项目名称:HackBulgaria,代码行数:90,代码来源:unit_test.py


注:本文中的account.Account.deposit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。