No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_settings_loader.py 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #-*- coding: utf-8 -*-
  2. import unittest
  3. from lodel.settings.settings_loader import SettingsLoader
  4. class SettingsLoaderTestCase(unittest.TestCase):
  5. def test_merge_getsection(self):
  6. """Tests merge and getSection functions """
  7. settings = SettingsLoader('/home/helene/lodel2/tests/settings/conf.d')
  8. a = settings.getsection('A')
  9. self.assertEqual(a,dict({"a":"a1","b":"b1,b2,b3","c":"toto","fhui":"njl"}))
  10. b = settings.getsection('B')
  11. self.assertEqual(b,dict({"ab":"art","bb":"bj,kl,mn","cb":"tatat"}))
  12. c = settings.getsection('C')
  13. self.assertEqual(c,dict({"ca":"a2","cb":"b4,b2,b3","cc":"titi"}))
  14. d = settings.getsection('D')
  15. for v in a:
  16. assert ('A','{"a":"a1","b":"b1,b2,b3","c":"toto","fhui":"njl"}')
  17. def maFonction(a):
  18. return a
  19. e=settings.getoption('A','a',maFonction)
  20. self.assertEqual(e,'a1')
  21. f=settings.getoption('B','bb',maFonction)
  22. self.assertEqual(f,"bj,kl,mn")
  23. g=settings.getremains()
  24. self.assertIsNotNone(g)
  25. e=settings.getoption('A','b',maFonction)
  26. e=settings.getoption('A','c',maFonction)
  27. e=settings.getoption('A','fhui',maFonction)
  28. f=settings.getoption('B','ab',maFonction)
  29. f=settings.getoption('B','cb',maFonction)
  30. f=settings.getoption('C','cb',maFonction)
  31. f=settings.getoption('C','ca',maFonction)
  32. f=settings.getoption('C','cc',maFonction)
  33. g=settings.getremains()
  34. self.assertEqual(g,[])