コード例 #1
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_getpaths(set1):
    #        hide
    # p15 -> p16  ->  p17 -> 19
    #         \_ p18_/  \_ p20
    pt = ProcTree()
    pt.init()
    assert pt.getPaths(set1.p15) == []
    assert pt.getPaths(set1.p19) == [[set1.p17, set1.p16, set1.p15],
                                     [set1.p17, set1.p18, set1.p16, set1.p15]]
    assert pt.getPaths(set1.p20) == [[set1.p17, set1.p16, set1.p15],
                                     [set1.p17, set1.p18, set1.p16, set1.p15]]
    # assert pt.getPaths(set1.p19, check_hide = True)  == [
    # 	[set1.p17, set1.p15], [set1.p17, set1.p18, set1.p15]]
    # assert pt.getPaths(set1.p20, check_hide = True)  == [
    # 	[set1.p17, set1.p15], [set1.p17, set1.p18, set1.p15]]

    # circulic dependence
    p21 = Proc()
    p22 = Proc()
    p23 = Proc()
    # p21 -> p22 -> p23 -> p21
    p21.depends = p23
    p23.depends = p22
    p22.depends = p21
    pt = ProcTree()
    pt.init()
    with pytest.raises(ProcTreeParseError):
        pt.getPaths(p23)
コード例 #2
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_getnexttorun(set2):
    # p15 -> p16  ->  p17 -> 19
    # p14 _/  \_ p18_/  \_ p20
    #           hide
    p1 = Proc()
    #ProcTree.register(p1)
    p2 = Proc()
    p2.depends = p1
    pt = ProcTree()
    pt.init()
    pt.setStarts([set2.p14, set2.p15])
    pt.NODES[set2.p14].ran = True
    assert pt.getNextToRun() is set2.p15
    pt.NODES[set2.p15].ran = True
    assert pt.getNextToRun() is set2.p16
    pt.NODES[set2.p16].ran = True
    assert pt.getNextToRun() is set2.p18
    pt.NODES[set2.p18].ran = True
    assert pt.getNextToRun() is set2.p17
    pt.NODES[set2.p17].ran = True
    assert pt.getNextToRun() is set2.p20
    pt.NODES[set2.p20].ran = True
    assert pt.getNextToRun() is set2.p19
    pt.NODES[set2.p19].ran = True
    assert pt.getNextToRun() is None
コード例 #3
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_getallpaths_single():
    p1 = Proc()
    ProcTree.register(p1)
    pt = ProcTree()

    pt.setStarts([p1])
    assert list(pt.getAllPaths()) == [[p1]]
コード例 #4
0
ファイル: testProcTree.py プロジェクト: taebow/PyPPL
 def testGetPathsToStarts(self, procs, starts, proc, paths):
     for p in procs:
         ProcTree.register(p)
     pt = ProcTree()
     pt.setStarts(starts)
     ps = pt.getPathsToStarts(proc)
     self.assertListEqual(ps, paths)
コード例 #5
0
ファイル: testProcTree.py プロジェクト: taebow/PyPPL
 def testGetPrevNextStr(self, procs, proc, which, out):
     for p in procs:
         ProcTree.register(p)
     ProcTree()
     if which == 'prev':
         self.assertEqual(ProcTree.getPrevStr(proc), out)
     else:
         self.assertEqual(ProcTree.getNextStr(proc), out)
コード例 #6
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_getprevstr():
    p6 = Proc()
    p7 = Proc()
    p7.depends = p6
    ProcTree.register(p6)
    ProcTree().init()
    assert ProcTree.getPrevStr(p6) == 'START'
    assert ProcTree.getPrevStr(p7) == '[p6]'
コード例 #7
0
ファイル: testProcTree.py プロジェクト: taebow/PyPPL
 def testGetNextToRun(self, procs, starts, haveran, out):
     for p in procs:
         ProcTree.register(p)
     pt = ProcTree()
     pt.setStarts(starts)
     for hr in haveran:
         ProcTree.NODES[hr].ran = True
     self.assertIs(pt.getNextToRun(), out)
コード例 #8
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_getnextstr():
    p8 = Proc()
    p9 = Proc()
    p9.depends = p8
    ProcTree.register(p8)
    ProcTree().init()
    assert ProcTree.getNextStr(p8) == '[p9]'
    assert ProcTree.getNextStr(p9) == 'END'
コード例 #9
0
ファイル: testProcTree.py プロジェクト: taebow/PyPPL
 def testGetPaths(self, procs, proc, paths, exception=None):
     for p in procs:
         ProcTree.register(p)
     pt = ProcTree()
     if exception:
         self.assertRaises(ProcTreeParseError, pt.getPaths, proc)
     else:
         ps = pt.getPaths(proc)
         self.assertListEqual(ps, paths)
コード例 #10
0
ファイル: testProcTree.py プロジェクト: taebow/PyPPL
 def testCheckPath(self, procs, starts, proc, passed):
     for p in procs:
         ProcTree.register(p)
     pt = ProcTree()
     pt.setStarts(starts)
     if isinstance(passed, bool):
         self.assertEqual(pt.checkPath(proc), passed)
     else:
         self.assertListEqual(pt.checkPath(proc), passed)
コード例 #11
0
ファイル: testProcTree.py プロジェクト: taebow/PyPPL
 def testGetEnds(self, procs, starts, ends, exception=None, msg=None):
     for p in procs:
         ProcTree.register(p)
     pt = ProcTree()
     pt.setStarts(starts)
     if exception:
         self.assertRaisesRegex(ProcTreeParseError, msg, pt.getEnds)
     else:
         self.assertCountEqual(pt.getEnds(), ends)
コード例 #12
0
ファイル: testProcTree.py プロジェクト: taebow/PyPPL
 def testReset(self, procs):
     for p in procs:
         ProcTree.register(p)
     ProcTree()
     ProcTree.reset()
     for node in ProcTree.NODES.values():
         self.assertListEqual(node.prev, [])
         self.assertListEqual(node.next, [])
         self.assertFalse(node.ran)
         self.assertFalse(node.start)
コード例 #13
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_getends_failed():
    p1 = Proc()
    p2 = Proc()
    p2.depends = p1
    ProcTree.register(p1)
    pt = ProcTree()
    pt.init()
    with pytest.raises(ProcTreeParseError):
        #Failed to determine end processes by start processes
        pt.getEnds()

    p3 = Proc()
    p3.depends = p2
    pt = ProcTree()
    pt.init()
    pt.setStarts([p3])
    with pytest.raises(ProcTreeParseError):
        # Failed to determine end processes, one of the paths cannot go through: 'p3 <- p2 <- p1'
        pt.getEnds()
コード例 #14
0
ファイル: testProcTree.py プロジェクト: taebow/PyPPL
 def testUnranProcs(self, procs, starts, outs):
     for p in procs:
         ProcTree.register(p)
     pt = ProcTree()
     pt.setStarts(starts)
     # run the pipeline
     p = pt.getNextToRun()
     while p:
         ProcTree.NODES[p].ran = True
         p = pt.getNextToRun()
     self.assertDictEqual(pt.unranProcs(), outs)
コード例 #15
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_chechpath(set2):
    # p15 -> p16  ->  p17 -> 19
    # p14 _/  \_ p18_/  \_ p20
    #           hide
    pt = ProcTree()
    pt.init()
    assert pt.checkPath(set2.p16) == [set2.p14]
    pt.setStarts([set2.p14])
    assert pt.checkPath(set2.p16) == [set2.p15]
    pt.setStarts([set2.p14, set2.p15])
    assert pt.checkPath(set2.p16) is True
コード例 #16
0
ファイル: testProcTree.py プロジェクト: taebow/PyPPL
 def testSetGetStarts(self, procs, starts):
     for p in procs:
         ProcTree.register(p)
     pt = ProcTree()
     pt.setStarts(starts)
     for proc in procs:
         if proc in starts:
             self.assertTrue(ProcTree.NODES[proc].start)
         else:
             self.assertFalse(ProcTree.NODES[proc].start)
     s = pt.getStarts()
     self.assertCountEqual(s, starts)
     self.assertCountEqual(pt.starts, starts)
コード例 #17
0
ファイル: testProcTree.py プロジェクト: taebow/PyPPL
 def testInit(self, procs):
     for p in procs:
         ProcTree.register(p)
     pt = ProcTree()
     self.assertEqual(pt.starts, [])
     self.assertEqual(pt.ends, [])
     for proc in procs:
         depends = proc.depends
         for depend in depends:
             nproc = ProcTree.NODES[proc]
             ndepend = ProcTree.NODES[depend]
             self.assertIn(nproc, ndepend.next)
             self.assertIn(ndepend, nproc.prev)
コード例 #18
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_getends(set2):

    # p15 -> p16  ->  p17 -> 19
    # p14 _/  \_ p18_/  \_ p20
    #           hide
    pt = ProcTree()
    pt.init()
    pt.setStarts([set2.p14, set2.p15])
    assert set(pt.getEnds()) == {set2.p19, set2.p20}
    assert set(pt.ends) == {set2.p19, set2.p20}
    assert set(pt.getEnds()) == {set2.p19, set2.p20}

    #set2.p19.hide = True
    pt.ends = []
コード例 #19
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_getallpaths(set2):
    # p15 -> p16  ->  p17 -> 19
    # p14 _/  \_ p18_/  \_ p20
    #         ##hide moved to plugin
    pt = ProcTree()
    pt.init()
    pt.setStarts([set2.p14, set2.p15])
    allpath = list(pt.getAllPaths())
    assert len(allpath) == 8
    assert [set2.p19, set2.p17, set2.p16, set2.p14] in allpath
    assert [set2.p19, set2.p17, set2.p16, set2.p15] in allpath
    assert [set2.p20, set2.p17, set2.p16, set2.p14] in allpath
    assert [set2.p20, set2.p17, set2.p16, set2.p15] in allpath
    assert [set2.p19, set2.p17, set2.p18, set2.p16, set2.p14] in allpath
    assert [set2.p19, set2.p17, set2.p18, set2.p16, set2.p15] in allpath
    assert [set2.p20, set2.p17, set2.p18, set2.p16, set2.p14] in allpath
    assert [set2.p20, set2.p17, set2.p18, set2.p16, set2.p15] in allpath
コード例 #20
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_getnext_and_reset():
    p10 = Proc()
    p11 = Proc()
    p11.depends = p10
    ProcTree.register(p10)
    ProcTree().init()
    assert ProcTree.getNext(p10) == [p11]
    assert ProcTree.getNext(p11) == []

    ProcTree.reset()
    ProcTree.NODES[p10].prev == []
    ProcTree.NODES[p10].next == []
    ProcTree.NODES[p11].prev == []
    ProcTree.NODES[p11].next == []
    ProcTree.NODES[p10].ran == False
    ProcTree.NODES[p10].start == False
    ProcTree.NODES[p11].ran == False
    ProcTree.NODES[p11].start == False
コード例 #21
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_getpathstostarts(set2):
    # p15 -> p16  ->  p17 -> 19
    # p14 _/  \_ p18_/  \_ p20
    #           hide
    pt = ProcTree()
    pt.init()
    pt.setStarts([set2.p15])
    assert pt.getPathsToStarts(set2.p15) == []
    assert pt.getPathsToStarts(
        set2.p19) == [[set2.p17, set2.p16, set2.p15],
                      [set2.p17, set2.p18, set2.p16, set2.p15]]
    assert pt.getPathsToStarts(
        set2.p20) == [[set2.p17, set2.p16, set2.p15],
                      [set2.p17, set2.p18, set2.p16, set2.p15]]
    # assert pt.getPathsToStarts(set2.p19, check_hide = True) == [[set2.p17, set2.p16, set2.p15]]
    # assert pt.getPathsToStarts(set2.p20, check_hide = True) == [[set2.p17, set2.p16, set2.p15]]

    pt.setStarts([set2.p14, set2.p15])
    assert pt.getPathsToStarts(set2.p14) == []
    assert pt.getPathsToStarts(set2.p15) == []
    assert pt.getPathsToStarts(set2.p16) == [[set2.p14], [set2.p15]]
    assert pt.getPathsToStarts(set2.p18) == [[set2.p16, set2.p14],
                                             [set2.p16, set2.p15]]
    assert pt.getPathsToStarts(set2.p17) == [
        [set2.p16, set2.p14],
        [set2.p16, set2.p15],
        [set2.p18, set2.p16, set2.p14],
        [set2.p18, set2.p16, set2.p15],
    ]
    assert pt.getPathsToStarts(set2.p19) == [
        [set2.p17, set2.p16, set2.p14],
        [set2.p17, set2.p16, set2.p15],
        [set2.p17, set2.p18, set2.p16, set2.p14],
        [set2.p17, set2.p18, set2.p16, set2.p15],
    ]
    assert pt.getPathsToStarts(set2.p20) == [
        [set2.p17, set2.p16, set2.p14],
        [set2.p17, set2.p16, set2.p15],
        [set2.p17, set2.p18, set2.p16, set2.p14],
        [set2.p17, set2.p18, set2.p16, set2.p15],
    ]
コード例 #22
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_init():
    p21 = Proc()
    p22 = Proc()
    p23 = Proc()
    p24 = Proc()
    p25 = Proc()
    p23.depends = p21, p22
    #p23.hide    = True
    p24.depends = p23
    p25.depends = p23
    ProcTree.register(p21)
    ProcTree.register(p22)

    pt = ProcTree()
    pt.init()
    # with pytest.raises(ProcHideError):
    # 	pt.init()
    assert p21 in ProcTree.NODES
    assert p22 in ProcTree.NODES
    assert p23 in ProcTree.NODES
    assert p24 in ProcTree.NODES
    assert p25 in ProcTree.NODES
    assert ProcTree.NODES[p21].prev == []
    assert ProcTree.NODES[p22].prev == []
    assert ProcTree.NODES[p23].prev == [
        ProcTree.NODES[p21], ProcTree.NODES[p22]
    ]
    assert ProcTree.NODES[p24].prev == [ProcTree.NODES[p23]]
    assert ProcTree.NODES[p25].prev == [ProcTree.NODES[p23]]
    assert ProcTree.NODES[p21].next == [ProcTree.NODES[p23]]
    assert ProcTree.NODES[p22].next == [ProcTree.NODES[p23]]
    assert ProcTree.NODES[p23].next == [
        ProcTree.NODES[p24], ProcTree.NODES[p25]
    ]
    assert ProcTree.NODES[p24].next == []
    assert ProcTree.NODES[p25].next == []
コード例 #23
0
ファイル: test_proctree.py プロジェクト: adi0321/PyPPL
def test_proctree_setgetstarts():
    p12 = Proc()
    p13 = Proc()
    p14 = Proc()
    #p14.hide = True
    p12.depends = p13
    ProcTree.register(p13)
    ProcTree.register(p14)
    pt = ProcTree()
    pt.init()
    # with pytest.raises(ProcHideError):
    # 	pt.setStarts([p14])
    pt.ends = [1, 2, 3]
    pt.setStarts([p13])
    assert ProcTree.NODES[p12].start == False
    assert ProcTree.NODES[p13].start == True
    assert ProcTree.NODES[p14].start == False
    assert pt.starts == [p13]
    assert pt.ends == []

    pt.starts = []
    assert pt.getStarts() == [p13]
    assert pt.starts == [p13]
    assert pt.getStarts() == [p13]
コード例 #24
0
ファイル: testProcTree.py プロジェクト: taebow/PyPPL
 def testGetAllPaths(self, procs, starts, paths):
     for p in procs:
         ProcTree.register(p)
     pt = ProcTree()
     pt.setStarts(starts)
     self.assertCountEqual(pt.getAllPaths(), paths)
コード例 #25
0
ファイル: testProcTree.py プロジェクト: taebow/PyPPL
 def testGetNext(self, procs, proc, outs):
     for p in procs:
         ProcTree.register(p)
     ProcTree()
     nexts = ProcTree.getNext(proc)
     self.assertCountEqual(nexts, outs)