-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_config.py
52 lines (34 loc) · 1.48 KB
/
test_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import pytest
from pkglts.config_management import Config
from pkglts.option.doc.option import OptionDoc
@pytest.fixture()
def opt():
return OptionDoc('doc')
def test_root_dir_is_defined(opt):
assert opt.root_dir() is not None
def test_update_parameters(opt):
cfg = {}
opt.update_parameters(cfg)
assert len(cfg['doc']) == 3
def test_config_check_description_exists(opt):
cfg = Config(dict(doc={'description': "mydescr", 'fmt': 'rst', 'keywords': []}))
assert cfg['doc']['description'] == "mydescr"
assert 'doc.description' not in opt.check(cfg)
def test_config_check_description_valid(opt):
cfg = Config(dict(doc={'description': "", 'fmt': 'rst', 'keywords': []}))
assert 'doc.description' in opt.check(cfg)
def test_config_check_keywords_exists(opt):
cfg = Config(dict(doc={'description': "mydescr", 'fmt': 'rst', 'keywords': []}))
assert len(cfg['doc']['keywords']) == 0
assert 'doc.keywords' not in opt.check(cfg)
def test_config_check_fmt_valid(opt):
cfg = Config(dict(doc={'description': "mydescr", 'fmt': 'walou', 'keywords': []}))
assert 'doc.fmt' in opt.check(cfg)
def test_require(opt):
cfg = Config(dict(base={}, doc={'fmt': 'rst'}))
assert len(opt.require('option', cfg)) == 1
assert len(opt.require('setup', cfg)) == 0
assert len(opt.require('install', cfg)) == 0
assert len(opt.require('dvlpt', cfg)) == 0
cfg = Config(dict(base={}, doc={'fmt': 'md'}))
assert len(opt.require('dvlpt', cfg)) == 1