Exemple #1
0
    def testFlowchart(self, start, fcfile, dotfile, errs=[]):

        with helpers.log2str():
            pp = PyPPL({'_log': {'file': None}})
        pp.start(start)
        with helpers.log2str(levels='all') as (out, err):
            pp.flowchart(fcfile=fcfile, dotfile=dotfile)
        self.assertTrue(path.isfile(fcfile))
        self.assertTrue(
            path.isfile(dotfile or path.splitext(fcfile)[0] + '.dot'))
        stderr = err.getvalue()
        for err in errs:
            self.assertIn(err, stderr)
            stderr = stderr[(stderr.find(err) + len(err)):]
Exemple #2
0
def test_showallroutes(pset, caplog, tmp_path):
    fcfile = tmp_path / 'test_showallroutes.svg'
    # p15 -> p16  ->  ps -> p19
    # p14 _/  \_ p18_/  \_ p20
    #           hide
    pset.p17.depends = []
    ps = ProcSet(Proc(id='p1'), Proc(id='p2'))
    ps.depends = pset.p16, pset.p18
    pset.p19.depends = ps
    pset.p20.depends = ps
    ppl = PyPPL().start(pset.p14, pset.p15)
    ppl.flowchart(fcfile)
    assert 'ALL ROUTES:' in caplog.text
    assert '  p14 -> p16 -> [@ps] -> p19' in caplog.text
    assert '  p14 -> p16 -> [@ps] -> p20' in caplog.text
    assert '  p15 -> p16 -> [@ps] -> p19' in caplog.text
    assert '  p15 -> p16 -> [@ps] -> p20' in caplog.text
Exemple #3
0
def test_flowchart(pset, caplog, tmp_path):
    for p in pset.values():
        p.input = {'a': [1]}
        p.output = 'a:var:{{i.a}}'
    ppl = PyPPL({
        'ppldir': tmp_path / 'test_flowchart_ppldir'
    }).start(pset.p14, pset.p15)
    ppl.counter = 0
    ppl.flowchart()
    assert 'Flowchart file saved to:' in caplog.text
    assert 'DOT file saved to:' in caplog.text
    assert fs.exists('./%s.pyppl.svg' % Path(ppl.name))
    assert fs.exists('./%s.pyppl.dot' % Path(ppl.name))

    dot = Path('./%s.pyppl.dot' % Path(ppl.name)).read_text()
    assert 'p17.test_flowchart" -> "p19.test_flowchart' in dot
    assert 'p17.test_flowchart" -> "p20.test_flowchart' in dot
    assert 'p16.test_flowchart" -> "p17.test_flowchart' in dot
    assert 'p16.test_flowchart" -> "p18.test_flowchart' not in dot  # hidden
    assert 'p14.test_flowchart" -> "p16.test_flowchart' in dot
    assert 'p15.test_flowchart" -> "p16.test_flowchart' in dot

    fs.remove('./%s.pyppl.svg' % Path(ppl.name))
    fs.remove('./%s.pyppl.dot' % Path(ppl.name))
Exemple #4
0
def test_flowchart(pset, caplog, tmp_path):
    for p in pset.values():
        p.input = {'a': [1]}
        p.output = 'a:var:{{i.a}}'
    ppl = PyPPL({
        'ppldir': tmp_path / 'test_flowchart_ppldir'
    }).start(pset.p14, pset.p15)
    ppl.counter = 0
    ppl.flowchart()
    assert 'Flowchart file saved to:' in caplog.text
    assert 'DOT file saved to:' in caplog.text
    assert fs.exists('./%s.pyppl.svg' % Path(sys.argv[0]).stem)
    assert fs.exists('./%s.pyppl.dot' % Path(sys.argv[0]).stem)

    dot = Path('./%s.pyppl.dot' % Path(sys.argv[0]).stem).read_text()
    assert 'p17 -> p19' in dot
    assert 'p17 -> p20' in dot
    assert 'p16 -> p17' in dot
    #assert 'p16 -> p18' in dot # hidden
    assert 'p14 -> p16' in dot
    assert 'p15 -> p16' in dot

    fs.remove('./%s.pyppl.svg' % Path(sys.argv[0]).stem)
    fs.remove('./%s.pyppl.dot' % Path(sys.argv[0]).stem)