Example #1
0
 def test_upstream_ids (self):
     start = datetime(2000, 1, 1)
     end = start + timedelta(weeks=1)
     a1 = Allocation(Project("-1"), Resource.fetch("-1"), 0, start, end)
     c1 = Charge(a1, 0)
     c1.datetime = datetime(2000, 1, 1)
     Session.add(c1)
     Session.flush()
     stdout, stderr = capture(lambda:
         print_charges_list([c1]))
     assert_equal_multiline(stdout.getvalue(), dedent("""\
         1      2000-01-01 -1       -1                        0.0
         """))
Example #2
0
 def test_charge (self):
     user1 = User.fetch("user1")
     project1 = Project.fetch("project1")
     res1 = Resource.fetch("res1")
     allocation1 = Allocation(project1, res1, 0,
         datetime(2000, 1, 1), datetime(2001, 1, 1))
     charge = Charge(allocation1, 0)
     charge.datetime = datetime(2000, 1, 1)
     Session.add(charge)
     Session.flush()
     stdout, stderr = capture(lambda:
         print_charges([charge]))
     assert_equal_multiline(stdout.getvalue(), dedent("""\
         Charge 1 -- 0.0
          * Datetime: 2000-01-01 00:00:00
          * Allocation: 1
          * Project: project1
          * Resource: res1
          * Comment: 
          * Job: None
         """))
Example #3
0
 def test_job_refund (self):
     user1 = User.fetch("user1")
     project1 = Project.fetch("project1")
     res1 = Resource.fetch("res1")
     allocation1 = Allocation(project1, res1, 0,
         datetime(2000, 1, 1), datetime(2001, 1, 1))
     charge = Charge(allocation1, 0)
     charge.job = Job("res1.1")
     refund = Refund(charge, 0)
     refund.datetime = datetime(2000, 1, 1)
     Session.add(refund)
     Session.flush()
     stdout, stderr = capture(lambda:
         print_refunds([refund]))
     assert_equal_multiline(stdout.getvalue(), dedent("""\
         Refund 1 -- 0.0
          * Datetime: 2000-01-01 00:00:00
          * Charge: 1
          * Allocation: 1
          * Project: project1
          * Resource: res1
          * Comment: 
          * Job: res1.1
         """))