當前位置: 首頁>>代碼示例>>Python>>正文


Python Account.deposit方法代碼示例

本文整理匯總了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)
開發者ID:smyrman,項目名稱:kikrit,代碼行數:29,代碼來源:tests.py

示例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)
開發者ID:smyrman,項目名稱:kikrit,代碼行數:29,代碼來源:tests.py

示例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)
開發者ID:smyrman,項目名稱:kikrit,代碼行數:18,代碼來源:tests.py

示例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)
開發者ID:smyrman,項目名稱:kikrit,代碼行數:25,代碼來源:tests.py


注:本文中的accounts.models.Account.deposit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。