Esempio n. 1
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))
Esempio n. 2
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)