Completed
Push — master ( ebbd13...afe8ce )
by Chris
01:11
created

test_make_dotfile_invalid_path()   A

Complexity

Conditions 2

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
from uuid import uuid1
2
3
import pytest
4
5
from flask_jsondash.data_utils import filetree_digraph
6
7
8
def test_make_dotfile(tmpdir):
9
    uid = uuid1()
10
    dirname = '{}'.format(uid)
11
    tmp = tmpdir.mkdir(dirname)
12
    for i in range(10):
13
        tmp.join('{}.txt'.format(i)).write('{}'.format(i))
14
    data = filetree_digraph.make_dotfile(tmp.strpath)
15
    # Ensure wrapping lines are proper digraph format.
16
    assert data.startswith('digraph {\n')
17
    assert data.endswith('\n}\n')
18
    lines = data.split('\n')
19
    # Ensure each line has the right dotfile format.
20
    for i, line in enumerate(lines[1:len(lines) - 2]):
21
        assert line == '\t"{0}" -> "{1}.txt";'.format(uid, i)
22
23
24
def test_make_dotfile_invalid_path(tmpdir):
25
    with pytest.raises(OSError):
26
        filetree_digraph.make_dotfile('invalid-path')
27