|
@@ -8,34 +8,36 @@ from lodel.settings.settings_loader import SettingsLoader
|
8
|
8
|
#A dummy validator that only returns the value
|
9
|
9
|
def dummy_validator(value): return value
|
10
|
10
|
#A dummy validator that always fails
|
11
|
|
-def dummy_validator_fails(value): raise ValueError("Fake validaion error")
|
|
11
|
+def dummy_validator_fails(value): raise ValueError("Fake validation error")
|
12
|
12
|
|
13
|
13
|
class SettingsLoaderTestCase(unittest.TestCase):
|
14
|
14
|
|
15
|
15
|
def test_merge_getsection(self):
|
16
|
16
|
"""Tests merge and getSection functions """
|
17
|
|
- settings = SettingsLoader('tests/settings/conf.d')
|
|
17
|
+ settings = SettingsLoader('tests/settings/settings_examples/conf.d')
|
18
|
18
|
def maFonction(a):
|
19
|
19
|
return a
|
20
|
|
- e=settings.getoption('A','a',maFonction)
|
|
20
|
+ e=settings.getoption('lodel2.A','a',maFonction)
|
21
|
21
|
self.assertEqual(e,'a1')
|
22
|
|
- f=settings.getoption('B','bb',maFonction)
|
|
22
|
+ f=settings.getoption('lodel2.B','bb',maFonction)
|
23
|
23
|
self.assertEqual(f,"bj,kl,mn")
|
24
|
24
|
g=settings.getremains()
|
25
|
25
|
self.assertIsNotNone(g)
|
26
|
|
- e=settings.getoption('A','b',maFonction)
|
27
|
|
- e=settings.getoption('A','c',maFonction)
|
28
|
|
- e=settings.getoption('A','fhui',maFonction)
|
29
|
|
- f=settings.getoption('B','ab',maFonction)
|
30
|
|
- f=settings.getoption('B','cb',maFonction)
|
31
|
|
- f=settings.getoption('C','cb',maFonction)
|
32
|
|
- f=settings.getoption('C','ca',maFonction)
|
33
|
|
- f=settings.getoption('C','cc',maFonction)
|
34
|
|
- f=settings.getoption('C','a',maFonction)
|
|
26
|
+ e=settings.getoption('lodel2.A','b',maFonction)
|
|
27
|
+ e=settings.getoption('lodel2.A','c',maFonction)
|
|
28
|
+ e=settings.getoption('lodel2.A','fhui',maFonction)
|
|
29
|
+ f=settings.getoption('lodel2.B','ab',maFonction)
|
|
30
|
+ f=settings.getoption('lodel2.B','cb',maFonction)
|
|
31
|
+ f=settings.getoption('lodel2.C','cb',maFonction)
|
|
32
|
+ f=settings.getoption('lodel2.C','ca',maFonction)
|
|
33
|
+ f=settings.getoption('lodel2.C','cc',maFonction)
|
|
34
|
+ f=settings.getoption('lodel2.C','a',maFonction)
|
|
35
|
+ f=settings.getoption('lodel2.A.e','a',maFonction)
|
|
36
|
+ f=settings.getoption('lodel2.A.e','titi',maFonction)
|
35
|
37
|
g=settings.getremains()
|
36
|
38
|
self.assertEqual(g,[])
|
37
|
39
|
with self.assertRaises(SettingsError):
|
38
|
|
- loader = SettingsLoader('tests/settings/conf_raise.d')
|
|
40
|
+ loader = SettingsLoader('tests/settings/settings_examples/conf_raise.d')
|
39
|
41
|
|
40
|
42
|
def test_merge(self):
|
41
|
43
|
""" Test merge of multiple configuration files """
|