-
Notifications
You must be signed in to change notification settings - Fork 33
/
test_config_global_source.py
51 lines (43 loc) · 1.8 KB
/
test_config_global_source.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
import unittest
from enum import Enum
from test.asserting.config_source import ConfigSourceAssertion, get_fixture_path
from vint.linting.config.config_global_source import ConfigGlobalSource
class TestConfigGlobalSource(ConfigSourceAssertion, unittest.TestCase):
def test_get_config_dict(self):
env = {
'home_path': get_fixture_path('dummy_home'),
'xdg_config_home': get_fixture_path('unexistent_xdg_config_home'),
}
expected_config_dict = {
'cmdargs': {
'verbose': bool,
'error-limit': int,
'severity': Enum,
}
}
config_source = self.initialize_config_source_with_env(ConfigGlobalSource, env)
self.assertConfigValueType(config_source, expected_config_dict)
def test_get_config_dict_with_no_global_config(self):
env = {
'home_path': get_fixture_path('unexistent_home'),
'xdg_config_home': get_fixture_path('unexistent_xdg_config_home'),
}
expected_config_dict = {}
config_source = self.initialize_config_source_with_env(ConfigGlobalSource, env)
self.assertConfigDict(config_source, expected_config_dict)
def test_get_config_dict_with_default_xdg_config_home(self):
env = {
'home_path': get_fixture_path('unexistent_home'),
'xdg_config_home': get_fixture_path('xdg_config_home'),
}
expected_config_dict = {
'cmdargs': {
'verbose': bool,
'error-limit': int,
'severity': Enum,
}
}
config_source = self.initialize_config_source_with_env(ConfigGlobalSource, env)
self.assertConfigValueType(config_source, expected_config_dict)
if __name__ == '__main__':
unittest.main()