[tests] add more core/config tests
This commit is contained in:
parent
b3d70c61f1
commit
5ee97dbb09
1 changed files with 34 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import unittest
|
||||
|
||||
import core.config
|
||||
|
@ -8,6 +9,7 @@ class config(unittest.TestCase):
|
|||
self.moreModules = [ 'this', 'module', 'here' ]
|
||||
self.someTheme = 'some-theme'
|
||||
self.someIconset = 'some-iconset'
|
||||
self.defaultConfig = core.config.Config([])
|
||||
|
||||
def test_module(self):
|
||||
cfg = core.config.Config([ '-m' ] + self.someModules)
|
||||
|
@ -18,8 +20,7 @@ class config(unittest.TestCase):
|
|||
self.assertEqual(self.someModules + self.moreModules, cfg.modules())
|
||||
|
||||
def test_default_interval(self):
|
||||
cfg = core.config.Config([])
|
||||
self.assertEqual(1, cfg.interval())
|
||||
self.assertEqual(1, self.defaultConfig.interval())
|
||||
|
||||
def test_interval(self):
|
||||
cfg = core.config.Config([ '-p', 'interval=4'])
|
||||
|
@ -30,19 +31,46 @@ class config(unittest.TestCase):
|
|||
self.assertEqual(0.5, cfg.interval())
|
||||
|
||||
def test_default_theme(self):
|
||||
cfg = core.config.Config([])
|
||||
self.assertEqual('default', cfg.theme())
|
||||
self.assertEqual('default', self.defaultConfig.theme())
|
||||
|
||||
def test_theme(self):
|
||||
cfg = core.config.Config(['-t', self.someTheme])
|
||||
self.assertEqual(self.someTheme, cfg.theme())
|
||||
|
||||
def test_default_iconset(self):
|
||||
cfg = core.config.Config([])
|
||||
self.assertEqual('auto', cfg.iconset())
|
||||
self.assertEqual('auto', self.defaultConfig.iconset())
|
||||
|
||||
def test_iconset(self):
|
||||
cfg = core.config.Config(['-i', self.someIconset])
|
||||
self.assertEqual(self.someIconset, cfg.iconset())
|
||||
|
||||
def test_right_to_left(self):
|
||||
cfg = core.config.Config(['-r'])
|
||||
self.assertTrue(cfg.reverse())
|
||||
self.assertFalse(self.defaultConfig.reverse())
|
||||
|
||||
def test_logfile(self):
|
||||
cfg = core.config.Config(['-f', 'my-custom-logfile'])
|
||||
self.assertEquals(None, self.defaultConfig.logfile())
|
||||
self.assertEquals('my-custom-logfile', cfg.logfile())
|
||||
|
||||
def test_all_modules(self):
|
||||
modules = core.config.all_modules()
|
||||
self.assertGreater(len(modules), 0)
|
||||
for module in modules:
|
||||
pyname = '{}.py'.format(module)
|
||||
base = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', 'modules'))
|
||||
self.assertTrue(os.path.exists(os.path.join(base, 'contrib', pyname)) or os.path.exists(os.path.join(base, 'core', pyname)))
|
||||
|
||||
def test_list_output(self):
|
||||
with unittest.mock.patch('core.config.sys') as sys:
|
||||
cfg = core.config.Config([ '-l', 'themes' ])
|
||||
cfg = core.config.Config([ '-l', 'modules' ])
|
||||
cfg = core.config.Config([ '-l', 'modules-markdown' ])
|
||||
# TODO: think of some plausibility testing here
|
||||
|
||||
def test_missing_parameter(self):
|
||||
cfg = core.config.Config([ '-p', 'test.key' ])
|
||||
self.assertEqual('no-value-set', cfg.get('test.key', 'no-value-set'))
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
|
Loading…
Reference in a new issue