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


Python Session.add_all方法代码示例

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


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

示例1: test_holds

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [as 别名]
 def test_holds (self):
     project_1 = Project.cached("1")
     project_2 = Project.cached("2")
     resource_1 = Resource.cached("1")
     resource_2 = Resource.cached("2")
     start = datetime(2000, 1, 1)
     end = start + timedelta(weeks=1)
     allocation_1 = Allocation(project_1, resource_1, 10, start, end)
     allocation_2 = Allocation(project_1, resource_1, 20, start, end)
     allocation_3 = Allocation(project_2, resource_1, 30, start, end)
     allocation_4 = Allocation(project_2, resource_2, 35, start, end)
     Hold(allocation_1, 10)
     h2 = Hold(allocation_2, 15)
     Hold(allocation_2, 5)
     Hold(allocation_4, 9)
     h5 = Hold(allocation_4, 8)
     h2.active = False
     h5.active = False
     allocations = [allocation_1, allocation_2, allocation_3, allocation_4]
     Session.add_all(allocations)
     Session.flush()
     assert_equal(
         list(allocation_summary(allocations)),
         [(allocation_1, 0, 0, 0),
          (allocation_2, 0, 0, 15),
          (allocation_3, 0, 0, 30),
          (allocation_4, 0, 0, 26)])
开发者ID:anderbubble,项目名称:cbank,代码行数:29,代码来源:test_queries.py

示例2: test_refunds

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [as 别名]
 def test_refunds (self):
     project_1 = Project.cached("1")
     project_2 = Project.cached("2")
     resource_1 = Resource.cached("1")
     resource_2 = Resource.cached("2")
     start = datetime(2000, 1, 1)
     end = start + timedelta(weeks=1)
     allocation_1 = Allocation(project_1, resource_1, 10, start, end)
     allocation_2 = Allocation(project_1, resource_1, 20, start, end)
     allocation_3 = Allocation(project_2, resource_1, 30, start, end)
     allocation_4 = Allocation(project_2, resource_2, 35, start, end)
     job_1 = Job("1.1")
     job_2 = Job("1.2")
     job_3 = Job("1.3")
     job_4 = Job("2.1")
     job_5 = Job("2.2")
     job_1.account = project_1
     job_2.account = project_1
     job_3.account = project_1
     job_4.account = project_2
     job_5.account = project_2
     job_1.charges = [Charge(allocation_1, 10)]
     job_2.charges = [Charge(allocation_2, 15)]
     job_3.charges = [Charge(allocation_2, 5)]
     job_4.charges = [Charge(allocation_4, 9)]
     job_5.charges = [Charge(allocation_4, 8)]
     Refund(job_1.charges[0], 4)
     Refund(job_2.charges[0], 3)
     Refund(job_2.charges[0], 5)
     Refund(job_5.charges[0], 8)
     Session.add_all([allocation_1, allocation_2, allocation_3, allocation_4])
     assert_equal(list(project_summary([project_1, project_2])),
                  [("1", 3, 18, 12), ("2", 2, 9, 56)])
开发者ID:anderbubble,项目名称:cbank,代码行数:35,代码来源:test_queries.py

示例3: test_expired_charges

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [as 别名]
 def test_expired_charges (self):
     project_1 = Project.cached("1")
     project_2 = Project.cached("2")
     resource_1 = Resource.cached("1")
     resource_2 = Resource.cached("2")
     start = datetime(2000, 1, 1)
     end = start + timedelta(weeks=1)
     allocation_1 = Allocation(project_1, resource_1, 10, start, start)
     allocation_2 = Allocation(project_1, resource_1, 20, start, end)
     allocation_3 = Allocation(project_2, resource_1, 30, start, end)
     allocation_4 = Allocation(project_2, resource_2, 35, start, start)
     Charge(allocation_1, 10)
     Charge(allocation_2, 15)
     Charge(allocation_2, 5)
     Charge(allocation_4, 9)
     Charge(allocation_4, 8)
     allocations = [allocation_1, allocation_2, allocation_3, allocation_4]
     Session.add_all(allocations)
     Session.flush()
     assert_equal(
         list(allocation_summary(allocations)),
         [(allocation_1, 0, 10, 0),
          (allocation_2, 0, 20, 0),
          (allocation_3, 0, 0, 30),
          (allocation_4, 0, 17, 0)])
开发者ID:anderbubble,项目名称:cbank,代码行数:27,代码来源:test_queries.py

示例4: test_jobs

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [as 别名]
 def test_jobs (self):
     project_1 = Project.cached("1")
     project_2 = Project.cached("2")
     resource_1 = Resource.cached("1")
     resource_2 = Resource.cached("1")
     start = datetime(2000, 1, 1)
     end = start + timedelta(weeks=1)
     allocation_1 = Allocation(project_1, resource_1, 0, start, end)
     allocation_2 = Allocation(project_2, resource_2, 0, start, end)
     job_1 = Job("1.1")
     job_2 = Job("1.2")
     job_3 = Job("1.3")
     job_4 = Job("2.1")
     job_5 = Job("2.2")
     charge_1 = Charge(allocation_1, 0)
     charge_2 = Charge(allocation_1, 0)
     charge_3 = Charge(allocation_1, 0)
     charge_4 = Charge(allocation_2, 0)
     charge_5 = Charge(allocation_2, 0)
     charge_1.job = job_1
     charge_2.job = job_2
     charge_3.job = job_3
     charge_4.job = job_4
     charge_5.job = job_5
     job_1.account = project_1
     job_2.account = project_1
     job_3.account = project_1
     job_4.account = project_2
     job_5.account = project_2
     Session.add_all([job_1, job_2, job_3, job_4, job_5])
     assert_equal(list(project_summary([project_1, project_2])),
                  [("1", 3, 0, 0), ("2", 2, 0, 0)])
开发者ID:anderbubble,项目名称:cbank,代码行数:34,代码来源:test_queries.py

示例5: test_with_jobs

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [as 别名]
 def test_with_jobs (self):
     job_1 = Job("1")
     job_1.user_id = "1"
     job_2 = Job("2")
     job_2.user_id = "2"
     dt = datetime(2000, 1, 1)
     Session.add_all([job_1, job_2])
     assert_equal(
         set(get_users()),
         set([User.cached("1"), User.cached("2")]))
开发者ID:anderbubble,项目名称:cbank,代码行数:12,代码来源:test_queries.py

示例6: test_charge_sum_one

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [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)
开发者ID:anderbubble,项目名称:cbank,代码行数:12,代码来源:test_mappers.py

示例7: test_refund_sum_zero

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [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)
开发者ID:anderbubble,项目名称:cbank,代码行数:12,代码来源:test_mappers.py

示例8: test_hold_sum_one

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [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)
开发者ID:anderbubble,项目名称:cbank,代码行数:12,代码来源:test_mappers.py

示例9: test_member_projects

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [as 别名]
 def test_member_projects (self):
     job_1 = Job("1")
     job_1.user_id = "1"
     job_2 = Job("2")
     job_2.user_id = "2"
     dt = datetime(2000, 1, 1)
     Session.add_all([job_1, job_2])
     assert_equal(
         get_users(member=Project.cached("1")),
         [User.cached("1")])
开发者ID:anderbubble,项目名称:cbank,代码行数:12,代码来源:test_queries.py

示例10: test_before_filter

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [as 别名]
 def test_before_filter (self):
     project_1 = Project.cached("1")
     project_2 = Project.cached("2")
     resource_1 = Resource.cached("1")
     resource_2 = Resource.cached("2")
     user_1 = User.cached("1")
     user_2 = User.cached("2")
     start = datetime(2000, 1, 1)
     end = start + timedelta(weeks=1)
     allocation_1 = Allocation(project_1, resource_1, 10, start, end)
     allocation_2 = Allocation(project_1, resource_1, 20, start, end)
     allocation_3 = Allocation(project_2, resource_1, 30, start, end)
     allocation_4 = Allocation(project_2, resource_2, 35, start, end)
     charge_1 = Charge(allocation_1, 10)
     charge_2 = Charge(allocation_2, 15)
     charge_3 = Charge(allocation_2, 5)
     charge_4 = Charge(allocation_4, 9)
     charge_5 = Charge(allocation_4, 8)
     Refund(charge_1, 4)
     Refund(charge_2, 3)
     Refund(charge_2, 5)
     Refund(charge_5, 8)
     Hold(allocation_4, 9)
     hold_2 = Hold(allocation_4, 8)
     hold_2.active = False
     charge_1.job = Job("1.1")
     charge_2.job = Job("1.2")
     charge_3.job = Job("1.3")
     charge_4.job = Job("2.1")
     charge_5.job = Job("2.2")
     charge_1.job.user = user_1
     charge_2.job.user = user_2
     charge_3.job.user = user_1
     charge_4.job.user = user_1
     charge_5.job.user = user_2
     charge_1.datetime = datetime(2000, 1, 2)
     charge_2.datetime = datetime(2000, 1, 3)
     charge_3.datetime = datetime(2000, 1, 4)
     charge_4.datetime = datetime(2000, 1, 5)
     charge_5.datetime = datetime(2000, 1, 6)
     charge_1.job.start = datetime(2000, 1, 1)
     charge_2.job.start = datetime(2000, 1, 2)
     charge_3.job.start = datetime(2000, 1, 3)
     charge_4.job.start = datetime(2000, 1, 4)
     charge_5.job.start = datetime(2000, 1, 5)
     allocations = [allocation_1, allocation_2, allocation_3, allocation_4]
     Session.add_all(allocations)
     Session.flush()
     assert_equal(
         list(allocation_summary(allocations, before=datetime(2000, 1, 4))),
         [(allocation_1, 1, 6, 4),
          (allocation_2, 2, 7, 8),
          (allocation_3, 0, 0, 30),
          (allocation_4, 0, 0, 17)])
开发者ID:anderbubble,项目名称:cbank,代码行数:56,代码来源:test_queries.py

示例11: test_hold_sum_two_with_one_inactive

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [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)
开发者ID:anderbubble,项目名称:cbank,代码行数:14,代码来源:test_mappers.py

示例12: test_refund_sum_two

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [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)
开发者ID:anderbubble,项目名称:cbank,代码行数:14,代码来源:test_mappers.py

示例13: test_negative_balance

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [as 别名]
 def test_negative_balance (self):
     start = datetime(2000, 1, 1)
     end = start + timedelta(weeks=1)
     allocation = Allocation(
         Project.cached("1"),
         Resource.cached("1"),
         10, start, end)
     Charge(allocation, 20)
     Session.add_all([allocation])
     Session.flush()
     assert_equal(list(allocation_summary([allocation])),
                  [(allocation, 0, 20, 0)])
开发者ID:anderbubble,项目名称:cbank,代码行数:14,代码来源:test_queries.py

示例14: test_holds_specific_resource

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [as 别名]
 def test_holds_specific_resource (self):
     project_1 = Project.cached("1")
     resource_1 = Resource.cached("1")
     resource_2 = Resource.cached("2")
     start = datetime(2000, 1, 1)
     end = start + timedelta(weeks=1)
     allocation_1 = Allocation(project_1, resource_1, 10, start, end)
     allocation_2 = Allocation(project_1, resource_2, 20, start, end)
     Hold(allocation_1, 10)
     Hold(allocation_2, 15)
     Session.add_all([allocation_1, allocation_2])
     assert_equal(list(project_summary([project_1], resources=[resource_2])),
                  [("1", 0, 0, 5)])
开发者ID:anderbubble,项目名称:cbank,代码行数:15,代码来源:test_queries.py

示例15: test_expired_allocations

# 需要导入模块: from cbank.model.queries import Session [as 别名]
# 或者: from cbank.model.queries.Session import add_all [as 别名]
 def test_expired_allocations (self):
     project_1 = Project.cached("1")
     project_2 = Project.cached("2")
     resource_1 = Resource.cached("1")
     resource_2 = Resource.cached("2")
     start = datetime(2000, 1, 1)
     end = start + timedelta(weeks=1)
     allocation_1 = Allocation(project_1, resource_1, 10, start, start)
     allocation_2 = Allocation(project_1, resource_1, 20, start, start)
     allocation_3 = Allocation(project_2, resource_1, 30, start, end)
     allocation_4 = Allocation(project_2, resource_2, 35, start, start)
     Session.add_all([
         allocation_1, allocation_2, allocation_3, allocation_4])
     assert_equal(list(project_summary([project_1, project_2])),
                  [("1", 0, 0, 0), ("2", 0, 0, 30)])
开发者ID:anderbubble,项目名称:cbank,代码行数:17,代码来源:test_queries.py


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