本文整理匯總了Python中cbank.model.queries.Session.query方法的典型用法代碼示例。如果您正苦於以下問題:Python Session.query方法的具體用法?Python Session.query怎麽用?Python Session.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cbank.model.queries.Session
的用法示例。
在下文中一共展示了Session.query方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_charge_sum_zero
# 需要導入模塊: from cbank.model.queries import Session [as 別名]
# 或者: from cbank.model.queries.Session import query [as 別名]
def test_charge_sum_zero (self):
allocation = Allocation(None, None, 0, datetime(2000, 1, 1), datetime(2001, 1, 1))
allocation.project_id = "project"
allocation.resource_id = "resource"
Session.add(allocation)
Session.commit()
Session.close()
allocation = Session.query(Allocation).one()
assert_equal(allocation._charge_sum, 0)
示例2: test_charge_sum_one
# 需要導入模塊: from cbank.model.queries import Session [as 別名]
# 或者: from cbank.model.queries.Session import query [as 別名]
def test_charge_sum_one (self):
allocation = Allocation(None, None, 0, datetime(2000, 1, 1), datetime(2001, 1, 1))
allocation.project_id = "project"
allocation.resource_id = "resource"
charge = Charge(allocation, 1)
Session.add_all([allocation, charge])
Session.commit()
Session.close()
allocation = Session.query(Allocation).one()
assert_equal(allocation._charge_sum, 1)
示例3: test_hold_sum_one
# 需要導入模塊: from cbank.model.queries import Session [as 別名]
# 或者: from cbank.model.queries.Session import query [as 別名]
def test_hold_sum_one (self):
allocation = Allocation(None, None, 0, datetime(2000, 1, 1), datetime(2001, 1, 1))
allocation.project_id = "project"
allocation.resource_id = "resource"
hold = Hold(allocation, 1)
Session.add_all([allocation, hold])
Session.commit()
Session.close()
allocation = Session.query(Allocation).one()
assert_equal(allocation._active_hold_sum, 1)
示例4: test_refund_sum_zero
# 需要導入模塊: from cbank.model.queries import Session [as 別名]
# 或者: from cbank.model.queries.Session import query [as 別名]
def test_refund_sum_zero (self):
allocation = Allocation(None, None, 0, datetime(2000, 1, 1), datetime(2001, 1, 1))
allocation.project_id = "project"
allocation.resource_id = "resource"
charge = Charge(allocation, 0)
Session.add_all([allocation, charge])
Session.commit()
Session.close()
charge = Session.query(Charge).one()
assert_equal(charge._refund_sum, 0)
示例5: test_hold_sum_two_with_one_inactive
# 需要導入模塊: from cbank.model.queries import Session [as 別名]
# 或者: from cbank.model.queries.Session import query [as 別名]
def test_hold_sum_two_with_one_inactive (self):
allocation = Allocation(None, None, 0, datetime(2000, 1, 1), datetime(2001, 1, 1))
allocation.project_id = "project"
allocation.resource_id = "resource"
hold_1 = Hold(allocation, 1)
hold_1.active = False
hold_2 = Hold(allocation, 2)
Session.add_all([allocation, hold_1, hold_2])
Session.commit()
Session.close()
allocation = Session.query(Allocation).one()
assert_equal(allocation._active_hold_sum, 2)
示例6: test_refund_sum_two
# 需要導入模塊: from cbank.model.queries import Session [as 別名]
# 或者: from cbank.model.queries.Session import query [as 別名]
def test_refund_sum_two (self):
allocation = Allocation(None, None, 0, datetime(2000, 1, 1), datetime(2001, 1, 1))
allocation.project_id = "project"
allocation.resource_id = "resource"
charge = Charge(allocation, 0)
refund_1 = Refund(charge, 1)
refund_2 = Refund(charge, 2)
Session.add_all([allocation, charge, refund_1, refund_2])
Session.commit()
Session.close()
allocation = Session.query(Allocation).one()
assert_equal(allocation._refund_sum, 3)