def test_blank (self): stdout, stderr = capture(lambda: print_holds_list([])) assert_equal_multiline(stdout.getvalue(), dedent("""\ """)) assert_equal_multiline(stderr.getvalue(), dedent("""\ # Date Resource Project Held ------ ---------- -------- --------------- ------------- ------------- 0.0 Units are undefined. """))
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) h1 = Hold(a1, 0) h1.datetime = datetime(2000, 1, 1) Session.add(h1) Session.flush() stdout, stderr = capture(lambda: print_holds_list([h1])) assert_equal_multiline(stdout.getvalue(), dedent("""\ 1 2000-01-01 -1 -1 0.0 """))
def test_holds (self): 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) h1 = Hold(a1, 10) h2 = Hold(a2, 15) h3 = Hold(a2, 5) h4 = Hold(a4, 9) h5 = Hold(a4, 8) for hold in (h1, h2, h3, h4, h5): hold.datetime = datetime(2000, 1, 1) Session.add_all([a1, a2, a3, a4]) Session.flush() stdout, stderr = capture(lambda: print_holds_list([h1, h2, h3, h4, h5])) assert_equal_multiline(stdout.getvalue(), dedent("""\ 1 2000-01-01 res1 project1 10.0 2 2000-01-01 res1 project1 15.0 3 2000-01-01 res1 project1 5.0 4 2000-01-01 res2 project2 9.0 5 2000-01-01 res2 project2 8.0 """)) assert_equal_multiline(stderr.getvalue(), dedent("""\ # Date Resource Project Held ------ ---------- -------- --------------- ------------- ------------- 47.0 Units are undefined. """))