diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/glibext/configuration.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/glibext/configuration.py b/tests/glibext/configuration.py index 786fc9e..880b445 100644 --- a/tests/glibext/configuration.py +++ b/tests/glibext/configuration.py @@ -4,7 +4,7 @@ gi.require_version('Gdk', '3.0') from gi.repository import Gdk from chrysacase import ChrysalideTestCase -from pychrysalide.glibext import ConfigParam +from pychrysalide.glibext import ConfigParam, GenConfig class TestConfiguration(ChrysalideTestCase): @@ -69,3 +69,38 @@ class TestConfiguration(ChrysalideTestCase): self.assertTrue('|' in str(param.state)) self.assertTrue('.' in str(param.type)) + + + def testConfiguration(self): + """Feed and browse a basic configuration.""" + + config = GenConfig() + self.assertIsNotNone(config) + self.assertIsNone(config.filename) + + for i in range(5): + param = ConfigParam('config.int.%u' % i, ConfigParam.ConfigParamType.INTEGER, i) + config.add(param) + + chain = '' + + for p in config.params: + chain += '%u' % p.value + + self.assertTrue(chain == ''.join([ '%u' % i for i in range(5) ])) + + found = config.search('config.int.3') + self.assertTrue(found.value == 3) + + found = config.search('config.int.33') + self.assertIsNone(found) + + for p in config.params: + p.value *= 10 + + chain = '' + + for p in config.params: + chain += '%u' % p.value + + self.assertTrue(chain == ''.join([ '%u' % (i * 10) for i in range(5) ])) |