Exemplo n.º 1
0
 def test_blank (self):
     stdout, stderr = capture(lambda: print_charges_list([]))
     assert_equal_multiline(stdout.getvalue(), dedent("""\
         """))
     assert_equal_multiline(stderr.getvalue(), dedent("""\
         #      Date       Resource Project               Charged
         ------ ---------- -------- --------------- -------------
                                                    -------------
                                                              0.0
         Units are undefined.
         """))
Exemplo n.º 2
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
         """))
Exemplo n.º 3
0
 def test_refunds (self):
     user1 = User.fetch("user1")
     user2 = User.fetch("user2")
     project1 = Project.fetch("project1")
     project2 = Project.fetch("project2")
     res1 = Resource.fetch("res1")
     res2 = Resource.fetch("res2")
     start = datetime(2000, 1, 1)
     end = start + timedelta(weeks=1)
     a1 = Allocation(project1, res1, 10, start, end)
     a2 = Allocation(project1, res1, 20, start, end)
     a3 = Allocation(project2, res1, 30, start, end)
     a4 = Allocation(project2, res2, 35, start, end)
     c1 = Charge(a1, 10)
     c2 = Charge(a2, 15)
     c3 = Charge(a2, 5)
     c4 = Charge(a4, 9)
     c5 = Charge(a4, 8)
     for charge in (c1, c2, c3, c4, c5):
         charge.datetime = datetime(2000, 1, 1)
     Refund(c1, 4)
     Refund(c2, 3)
     Refund(c2, 5)
     Refund(c5, 8)
     Session.add_all([a1, a2, a3, a4])
     Session.flush()
     stdout, stderr = capture(lambda:
         print_charges_list([c1, c2, c3, c4, c5]))
     assert_equal_multiline(stdout.getvalue(), dedent("""\
         1      2000-01-01 res1     project1                  6.0
         2      2000-01-01 res1     project1                  7.0
         3      2000-01-01 res1     project1                  5.0
         4      2000-01-01 res2     project2                  9.0
         5      2000-01-01 res2     project2                  0.0
         """))
     assert_equal_multiline(stderr.getvalue(), dedent("""\
         #      Date       Resource Project               Charged
         ------ ---------- -------- --------------- -------------
                                                    -------------
                                                             27.0
         Units are undefined.
         """))