本文整理汇总了Python中accounts.models.Account.deposit方法的典型用法代码示例。如果您正苦于以下问题:Python Account.deposit方法的具体用法?Python Account.deposit怎么用?Python Account.deposit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.Account
的用法示例。
在下文中一共展示了Account.deposit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ordinary_purchase
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import deposit [as 别名]
def test_ordinary_purchase(self):
"""Test basic purchases (ordinary price)
"""
account = Account(name="tset")
account.deposit(500) # Depost issues the save routine
operator = None
m1 = Merchandise(name="m1", internal_price=3, ordinary_price=4)
m1.save()
m2 = Merchandise(name="m2", internal_price=2, ordinary_price=4)
m2.save()
merchandise_list = [m1, m1, m1, m2]
# Test a basic purchase:
total_price = sum(m.ordinary_price for m in merchandise_list)
trans = buy_merchandise(account, merchandise_list, operator)
account = Account.objects.get(id=account.id) # Force update
self.failUnlessEqual(trans.amount, -total_price)
self.failUnlessEqual(account.balance, 500 - total_price)
# Test if the number of purchased items related to the transaction is
# correct:
pm_count = PurchasedItem.objects.filter(transaction=trans).count()
item_count = len(merchandise_list)
self.failUnlessEqual(pm_count, item_count)
示例2: test_against_cascade_deletion_of_purchaseditem
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import deposit [as 别名]
def test_against_cascade_deletion_of_purchaseditem(self):
"""Test that purchased items are not removed when related merchandise
is
"""
account = Account(name="tset")
account.deposit(500) # Depost issues the save routine
operator = None
m1 = Merchandise(name="m1", internal_price=3, ordinary_price=4)
m1.save()
m2 = Merchandise(name="m2", internal_price=2, ordinary_price=4)
m2.save()
# Test a basic purchase:
trans = buy_merchandise(account, [m1], operator)
# Test that transactions are not deleted when related merchandise is,
# and that backup information is stored to merchandise_tags and
# merchandise_name:
pm1_id = PurchasedItem.objects.get(transaction=trans).id
merchandise_name = m1.name[:30]
merchandise_tags = "|".join((unicode(t) for t in m1.tags.all()))[:30]
m1.delete()
pm1 = PurchasedItem.objects.get(id=pm1_id)
self.failUnlessEqual(pm1.merchandise_name, merchandise_name)
self.failUnlessEqual(pm1.merchandise_tags, merchandise_tags)
示例3: test_illegal_purchase
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import deposit [as 别名]
def test_illegal_purchase(self):
"""Test if purchases are canceled if they should not be allowed
"""
account = Account(name="tset")
account.deposit(3) # Deposit issues the save routine
operator = None
m1 = Merchandise(name="m1", internal_price=3, ordinary_price=4)
m1.save()
# Test illegal purchase:
trans = buy_merchandise(account, [m1], operator)
account = Account.objects.get(id=account.id) # Force update
self.failUnlessEqual(trans, None)
self.failUnlessEqual(account.balance, 3)
示例4: test_internal_purchase
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import deposit [as 别名]
def test_internal_purchase(self):
"""Test basic purchases (internal price)
"""
limit_group = LimitGroup(internal_price=True)
limit_group.save()
account = Account(name="tset", limit_group=limit_group)
account.deposit(500) # Depost issues the save routine
operator = None
m1 = Merchandise(name="m1", internal_price=3, ordinary_price=4)
m1.save()
m2 = Merchandise(name="m2", internal_price=2, ordinary_price=4)
m2.save()
merchandise_list = [m1, m1, m1, m2]
# Test internal purchase:
total_price = sum(m.internal_price for m in merchandise_list)
trans = buy_merchandise(account, merchandise_list, operator)
account = Account.objects.get(id=account.id) # Force update
self.failUnlessEqual(trans.amount, -total_price)
self.failUnlessEqual(account.balance, 500 - total_price)