Exemplo n.º 1
0
def test_make_dotfile_skip_empty(monkeypatch, tmpdir):
    uid = str(uuid1())
    tmp = tmpdir.mkdir(uid)
    # Add a bunch of empty pointers
    results = [' ->' for _ in range(10)] + ['foo -> bar']
    monkeypatch.setattr(
        filetree_digraph, 'path_hierarchy', lambda *a, **k: results)
    data = filetree_digraph.make_dotfile(tmp.strpath)
    assert data == 'digraph {\n\tfoo -> bar;\n}\n'
Exemplo n.º 2
0
def test_make_dotfile(tmpdir):
    uid = str(uuid1())
    tmp = tmpdir.mkdir(uid)
    for i in range(4):
        tmp.join('{}.txt'.format(i)).write('{}'.format(i))
    data = filetree_digraph.make_dotfile(tmp.strpath)
    # Ensure wrapping lines are proper digraph format.
    assert data.startswith('digraph {\n')
    assert data.endswith('\n}\n')
    lines = data.split('\n')
    # Ensure each line has the right dotfile format.
    for i, line in enumerate(lines[1:len(lines) - 2]):
        assert line == '\t"{0}" -> "{1}.txt";'.format(uid, i)
Exemplo n.º 3
0
def test_make_dotfile_invalid_path_none():
    with pytest.raises(AssertionError):
        filetree_digraph.make_dotfile(None)
Exemplo n.º 4
0
def test_make_dotfile_invalid_path():
    with pytest.raises(OSError):
        filetree_digraph.make_dotfile('invalid-path')