def test_refund_amount_negative (self): a = Allocation(Project("1"), Resource("1"), 10, datetime.now(), datetime.now()) c = Charge(a, 5) r = Refund(c, -1) Session.add(r) Session.commit()
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)
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)
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)
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)
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)
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)
def test_charge_amount_negative (self): a = Allocation(Project("1"), Resource("1"), 10, datetime.now(), datetime.now()) c = Charge(a, -1) Session.add(c) Session.commit()
def test_hold_amount_negative (self): a = Allocation(Project("1"), Resource("1"), 10, datetime.now(), datetime.now()) h = Hold(a, -1) Session.add(h) Session.commit()
def test_allocation_amount_negative (self): a = Allocation(Project("1"), Resource("1"), -1, datetime.now(), datetime.now()) Session.add(a) Session.commit()