test_config   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 41
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 11

5 Functions

Rating   Name   Duplication   Size   Complexity  
A test_config_2() 0 11 2
A test_config_4() 0 6 3
A test_config_3() 0 14 2
A test_config_1() 0 6 2
A test_config_5() 0 3 2
1
from yfrake.config import utils
2
from yfrake import client, config
3
import pytest
4
import os
5
6
7
def test_config_1():
8
    path = config.file
9
    assert path == utils.get_default_config_path()
10
    with pytest.raises(TypeError):
11
        del config.file
12
    config.file = path
13
14
15
def test_config_2():
16
    assert config.is_locked() is False
17
18
    @client.session
19
    def main():
20
        with pytest.raises(RuntimeError):
21
            config.file = 'asdfg'
22
        assert config.is_locked() is True
23
    main()
24
25
    assert config.is_locked() is False
26
27
28
def test_config_3():
29
    assert not config.HERE.exists()
30
    config.file = config.HERE
31
    assert config.HERE.exists()
32
33
    @client.session
34
    def main():
35
        with pytest.raises(RuntimeError):
36
            config.file = config.HERE
37
    main()
38
39
    assert config.HERE.exists()
40
    os.remove(config.HERE)
41
    assert not config.HERE.exists()
42
43
44
def test_config_4():
45
    assert isinstance(config.settings, dict)
46
    with pytest.raises(TypeError):
47
        config.settings = dict()
48
    with pytest.raises(TypeError):
49
        del config.settings
50
51
52
def test_config_5():
53
    with pytest.raises(RuntimeError):
54
        config.file = 'bad/path'
55